home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / tcxl551.arc / TCXLDEMO.EXE / lha / DEMO / TCXLDEMO.C < prev    next >
C/C++ Source or Header  |  1990-10-01  |  81KB  |  2,639 lines

  1. /*=====[ The TesSeRact(TM) CXL User Interface Development System ]======*
  2.  | Copyright (c) 1987-1990, Innovative Data Concepts. All Rights Reserved
  3.  |
  4.  | This Library is part of IDC's TesSeRact Development Tools product
  5.  | line. For information about other IDC products, call 1-215-884-3373.
  6.  *----------------------------------------------------------------------*
  7.  |
  8.  |                       TCXL Demonstration Program
  9.  |
  10.  | Syntax:  TCXLDEMO [-switches]
  11.  |
  12.  |    -c  = CGA snow elimination
  13.  |    -b  = BIOS screen writing
  14.  |    -m  = force monochrome text attributes
  15.  |
  16.  | Compiler command lines:
  17.  |
  18.  |    MSC 5.1/6.0 :     cl /Ot /AS /Gs tcxldemo.c tcxlmss.lib
  19.  |    QC  2.0/2.5 :     qcl /Ot /AS /Gs tcxldemo.c tcxlmss.lib
  20.  |    TC 2.0/TC++ 1.0 : tcc -ms -d -N- -k- -O -Z tcxldemo.c tcxltcs.lib
  21.  |    ZTC 2.1 :         ztc -ms -o -b tcxldemo.c tcxlzts.lib
  22.  |
  23.  *----------------------------------------------------------------------*
  24.  | PGS : $Id: tcxldemo.c 5.51 90/10/01 00:00:00 MLM Release Locker: MLM $
  25.  | $Log:    tcxldemo.c $
  26.  | Revision 5.51  90/10/01  00:00:00  MLM
  27.  | TCXL 5.51
  28.  | 
  29.  *======================================================================*/
  30. #include <ctype.h>
  31. #include <dos.h>
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include <string.h>
  35. #include <TCXLdos.h>
  36. #if(_TCXL_cc_ == 1)                                      /* Turbo C     */
  37. #  include <alloc.h>
  38. #endif
  39. #if(_TCXL_cc_ == 3)                                      /* MicroSoft C */
  40. #  include  <malloc.h>
  41. #  define     farmalloc(s)   _fmalloc(s)
  42. #  define     farfree(p)     _ffree(p)
  43. #endif
  44. #include <TCXLkey.h>
  45. #include <TCXLmou.h>
  46. #include <TCXLstr.h>
  47. #include <TCXLsel.h>
  48. #include <TCXLmnu.h>
  49. #include <TCXLent.h>
  50. #include <TCXLhlp.h>
  51. #include <TCXLmem.h>
  52. #include <_TCXLvid.h>
  53. #include <TCXLcvt.h>
  54. #include <TCXLfar.h>
  55. #include <TCXLprn.h>
  56. #include <TCXLcod.h>
  57.  
  58. TYP union Vcel FAR *VcelFP;                               /* user type  */
  59.  
  60. /*---------------------[ Local Function prototypes ]--------------------*/
  61.  
  62. VOID  CTYP  ConfirmQuit(NOARG);        /* setup and control             */
  63. VOID  CTYP  ErrorExit(IntT errnum);
  64. VOID  CTYP  Initialize(NOARG);
  65. VOID  CTYP  ParseCmdLine(IntT argc, ChrP argv[]);
  66. VOID  CTYP  OpenBkgrnd(NOARG);
  67. VOID  CTYP  MainMenu(NOARG);
  68. VOID  CTYP  MoveBarDn(NOARG);
  69. VOID  CTYP  NormalExit(NOARG);
  70.  
  71. VOID  CTYP  AddShadow(NOARG);          /* general utility               */
  72. VOID  CTYP  DemoWait(NOARG);
  73. VcelFP   CTYP  FarVsave(IntT Atr);
  74. VOID  CTYP  FarVrestore(VcelFP FarPtr);
  75. VOID  CTYP  HorzLine(IntT wrow, IntT wcol, IntT count, IntT attr);
  76. VOID  CTYP  PressAKey(IntT wrow);
  77. VOID  CTYP  PressAKey1(IntT wrow, IntT wait);
  78. VOID  CTYP  VertLine(IntT wrow, IntT wcol, IntT count, IntT attr);
  79.  
  80. VOID  CTYP  MenuDemo(NOARG);           /* Menu System demo              */
  81. VOID  CTYP  ChangeSize(NOARG);
  82. IntT  CTYP  CheckDate(ChrP buf);
  83. VOID  CTYP  Directory(NOARG);
  84. VOID  CTYP  DispSureMsg(NOARG);
  85. VOID  CTYP  DisplayTitle(IntT tpos);
  86. VOID  CTYP  DoNothing(NOARG);
  87. VOID  CTYP  Execute(NOARG);
  88. VOID  CTYP  DrawEditor(IntT Lmar, IntT Rmar);
  89. VOID  CTYP  OsShell(NOARG);
  90. VOID  CTYP  OsShell1(ChrP Cmd);
  91. VOID  CTYP  ParseDate(ChrP buf, IntP month, IntP day, IntP year);
  92. VOID  CTYP  PopupDemo(NOARG);
  93. VOID  CTYP  PreHelp(NOARG);
  94. VOID  CTYP  PreMenu1(NOARG);
  95. VOID  CTYP  PrePick1(NOARG);
  96. VOID  CTYP  QuitWindow(NOARG);
  97. VOID  CTYP  RMargin(NOARG);
  98. VOID  CTYP  SetupMenu(NOARG);
  99. VOID  CTYP  ToggleBlock(NOARG);
  100. VOID  CTYP  ToggleYN(NOARG);
  101. VOID  CTYP  UpdateClock(NOARG);
  102. IntT  CTYP  ValidMarg(ChrP Input);
  103. IntT  CTYP  ValidModes(NOARG);
  104.  
  105. VOID  CTYP  EntryDemo(NOARG);          /* Entry System demo             */
  106. VOID  CTYP  DisplayDate(NOARG);
  107. WrdT  CTYP  GetKey(IntP done);
  108. VOID  CTYP  PickCompiler(NOARG);
  109. VOID  CTYP  PrintOrder(NOARG);
  110.  
  111. VOID  CTYP  SelectDemo(NOARG);         /* Selection System demo         */
  112. VOID  CTYP  YouSelected(ChrP str);
  113.  
  114. VOID  CTYP  WinDemo(NOARG);            /* Window System demo            */
  115. VOID  CTYP  ActivDemo(NOARG);
  116. VOID  CTYP  AttrDemo(NOARG);
  117. VOID  CTYP  BordDemo(NOARG);
  118. VOID  CTYP  ChgWindAttr(IntT battr, IntT wattr);
  119. VOID  CTYP  CloseWinDemo(NOARG);
  120. VOID  CTYP  CopyDemo(NOARG);
  121. VOID  CTYP  DragWindow(IntT nsrow, IntT nscol);
  122. VOID  CTYP  HideDemo(NOARG);
  123. VOID  CTYP  MoveDemo(NOARG);
  124. VOID  CTYP  MoveWindow(IntT nsrow, IntT nscol);
  125. VOID  CTYP  ResizeDemo(NOARG);
  126. VOID  CTYP  ScrollDemo(NOARG);
  127. VOID  CTYP  SizeWindow(IntT nerow, IntT necol);
  128. VOID  CTYP  TLineDemo(NOARG);
  129. VOID  CTYP  TitleDemo(NOARG);
  130.  
  131. VOID  CTYP  InputDemo(NOARG);          /* Input System demo             */
  132. VOID  CTYP  RestoreCursor(NOARG);
  133.  
  134. VOID  CTYP  StringDemo(NOARG);         /* Strings System demo           */
  135. VOID  CTYP  Dstrmatch(NOARG);
  136. VOID  CTYP  Dstrtrim(NOARG);
  137. VOID  CTYP  Dstrchg(NOARG);
  138. VOID  CTYP  Dstrchksum(NOARG);
  139. VOID  CTYP  Dstrdel(NOARG);
  140. VOID  CTYP  Dstrinc(NOARG);
  141. VOID  CTYP  Dstrsrep(NOARG);
  142. VOID  CTYP  Dstrmid (NOARG);
  143. VOID  CTYP  Dstrljust(NOARG);
  144. VOID  CTYP  Dstrblank(NOARG);
  145.  
  146. VOID  CTYP  TcxlInfo(NOARG);           /* TCXL info display             */
  147.  
  148. /*-----------------------[ help category numbers ]----------------------*/
  149.  
  150. #define  H_NONE      0
  151. #define  H_GLOBAL    1
  152. #define  H_WINDOWING 2
  153. #define  H_MENUING   3
  154. #define  H_LISTPICK  4
  155. #define  H_STRPICK   5
  156. #define  H_FILEPICK  6
  157. #define  H_DATAENTRY 7
  158. #define  H_EDITKEYS  8
  159. #define  H_DATE      9
  160. #define  H_FIRSTNAME 10
  161. #define  H_INITIAL   11
  162. #define  H_LASTNAME  12
  163. #define  H_CITY      13
  164. #define  H_STATE     14
  165. #define  H_ZIPCODE   15
  166. #define  H_COMPILER  16
  167. #define  H_AMOUNT    17
  168. #define  H_NUMERIC   18
  169. #define  H_PULLDOWN  19
  170. #define  H_FILE      20
  171. #define  H_EDITING   21
  172. #define  H_LOAD      22
  173. #define  H_SAVE      23
  174. #define  H_RENAME    24
  175. #define  H_NEW       25
  176. #define  H_DIRECTORY 26
  177. #define  H_EXECUTE   27
  178. #define  H_OSSHELL   28
  179. #define  H_QUIT      29
  180. #define  H_SCROLL    30
  181. #define  H_CHGATTR   31
  182. #define  H_CHGBORD   32
  183. #define  H_WINTITLE  33
  184. #define  H_RESIZE    34
  185. #define  H_TEXTLINE  35
  186. #define  H_WINMOVE   36
  187. #define  H_WINHIDE   37
  188. #define  H_ACTIVATE  38
  189. #define  H_WINCOPY   39
  190. #define  H_PICKATTR  40
  191. #define  H_INPUT     41
  192. #define  H_STRINGS   42
  193. #define  H_DEFAULTS  43
  194. #define  H_RUN       44
  195. #define  H_OPTIONS   45
  196.  
  197. /*------------------[ miscellaneous global variables ]------------------*/
  198.  
  199. VcelFP savescrn;                       /* ptr to saved DOS screen       */
  200. VposT rc;                              /* starting cursor position      */
  201. WndT w[10];                            /* window array for window demo  */
  202. IntT LeftRow, LeftCol, RightRow, RightCol;   /* main menu coords        */
  203. IntT DemoFast;                         /* window delay flag             */
  204. ChrP UvVal[21];                        /* used in menu demo             */
  205. IntT UvMd[21];                         /* "    "  "    "                */
  206.  
  207. /*------------------[ fields used in data entry demo ]------------------*/
  208.  
  209. ChrT date[7], firstname[16], initial[2], lastname[26], address[41],
  210.     city[21], state[3], zipcode[10], phone[11], compiler[16],
  211.     amtenc[8], comments[71], ssan[10], company[41];
  212.  
  213. /*-----------------------------[ constants ]----------------------------*/
  214.  
  215. ChrP error_text[] =     /* global error message table                   */
  216. {
  217.    NULL,                /* errnum = 0, no error                         */
  218.    NULL,                /* errnum = 1, windowing error                  */
  219.    "Usage : TCXLDEMO [-switches]\n\n"
  220.    "\t-c = CGA snow elimination\n"
  221.    "\t-b = BIOS screen writing\n"
  222.    "\t-m = force monochrome text attributes",
  223.    "Out of memory!",
  224.    "Far Heap Exhausted!"
  225. };
  226.  
  227. ChrP months[] =         /* months table -- used in selection demo       */
  228. {
  229.    "January", "February", "March", "April", "May", "June", "July",
  230.    "August", "September", "October", "November", "December", NULL
  231. };
  232.  
  233. ChrP prn_ports[] =      /* printer ports table -- used in selection demo*/
  234. {
  235.    "PRN", "LPT1", "LPT2", "COM1", "COM2", NULL
  236. };
  237.  
  238. ChrP compilers[] =      /* compiler table -- used in entry demo         */
  239. {
  240.    "Microsoft C", "Quick C", "Turbo C/C++", "Zortech C/C++"
  241. };
  242.                         /* used in strings demo                         */
  243. ChrP BefAft = " Before: <%s>\n  After: <%s>\n";
  244.  
  245. TYP struct _info
  246. {
  247.    IntT row;                           /* row to display on             */
  248.    IntT Atr;                           /* display attribute             */
  249.    ChrP Str;                           /* string to display             */
  250. }   INFO;
  251.  
  252. #define  INFO_CNT 14
  253.  
  254. INFO TcxlI[INFO_CNT] =  /* text displayed in Information screen         */
  255. {
  256.    {  1, WHITE|_RED,
  257.      "The TesSeRact(TM) CXL User Interface Development System" },
  258.    {  2, WHITE|_RED,
  259.       "Copyright (c) 1987-1990, Innovative Data Concepts" },
  260.    {  3, WHITE|_RED,
  261.       "All Rights Reserved" },
  262.    {  5, BLACK|_RED,
  263.       "TCXL is a Full-Featured C Development System that supports" },
  264.    {  6, BLACK|_RED,
  265.       "Microsoft C, QuickC, Turbo C/C++, and Zortech C/C++. There" },
  266.    {  7, BLACK|_RED,
  267.       "are over  410  functions available for use." },
  268.    {  9, WHITE|_RED, "Innovative Data Concepts" },
  269.    { 10, WHITE|_RED, "1657 The Fairways, Suite 101" },
  270.    { 11, WHITE|_RED, "Jenkintown, PA 19046 USA" },
  271.    { 12, WHITE|_RED, "1-215-884-3353 (Support)" },
  272.    { 13, WHITE|_RED, "1-800-926-4551 (Sales)" },
  273.    { 14, WHITE|_RED, "1-215-886-4225 (FAX)" },
  274.    { 15, WHITE|_RED, "CompuServe 76702,1361" },
  275.    { 16, WHITE|_RED, "MCIMAIL 315-5415" },
  276. };
  277.  
  278. TYP struct _EntDem
  279. {
  280.    IntT Prow;                             /* row for prompt             */
  281.    IntT Pcol;                             /* column for prompt          */
  282.    IntT Frow;                             /* EntFld() row               */
  283.    IntT Fcol;                             /* "        col               */
  284.    IntT Fflg;                             /* "        flag              */
  285.    IntT Ftag;                             /* "        field tag         */
  286.    IntT Htag;                             /* "        help tag          */
  287.    KeyT Fkey;                             /* FldKey() hot key           */
  288.    IfcpCP Val;                            /* EntFld() validation func   */
  289.    VfvCP FunBef;                          /* FldFun() before func       */
  290.    VfvCP FunAft;                          /* "        after func        */
  291.    ChrP Field;                            /* EntFld() field buffer      */
  292.    ChrP FmtStr;                           /* "        format string     */
  293.    ChrP Prompt;                           /* prompt text                */
  294. }   ENTDEM;
  295.  
  296. #define  DEMO_CNT 13
  297.  
  298. ENTDEM DmFld[DEMO_CNT] =               /* field data for entry demo     */
  299. {
  300.    {  1, 3, 1, 16, FLD_NUL, 1, H_DATE, Key_A_D, CheckDate, NULL,
  301.       DisplayDate, date, "<01>#'/'<0123>#'/'##", "Date" },
  302.    {  3, 3, 3, 16, FLD_NUL, 2, H_FIRSTNAME, Key_A_F, NULL, NULL, NULL,
  303.       firstname, "MMMMMMMMMMMMMMM", "First Name" },
  304.    {  3, 37, 3, 47, FLD_NUL, 3, H_INITIAL, Key_A_I, NULL, NULL, NULL,
  305.       initial, "U'.'", "Initial" },
  306.    {  5, 3, 5, 16, FLD_NUL, 4, H_LASTNAME, Key_A_L, NULL, NULL, NULL,
  307.       lastname, "MMMMMMMMMMMMMMMMMMMMMMMMM", "Last Name" },
  308.    {  7, 3, 7, 16, FLD_MIX, 5, H_NONE, Key_A_O, NULL, NULL, NULL,
  309.       company, "****************************************", "Company" },
  310.    {  9, 3, 9, 16, FLD_MIX, 6, H_NONE, Key_A_A, NULL, NULL, NULL,
  311.       address, "****************************************", "Address" },
  312.    { 11, 3, 11, 16, FLD_NUL, 7, H_CITY, Key_A_C, NULL, NULL, NULL,
  313.       city, "MMMMMMMMMMMMMMMMMMMM", "City" },
  314.    { 11, 41, 11, 50, FLD_NUL, 8, H_STATE, Key_A_S, NULL, NULL, NULL,
  315.       state, "UU", "State" },
  316.    { 13, 3, 13, 16, FLD_NUL, 9, H_ZIPCODE, Key_A_Z, NULL, NULL, NULL,
  317.       zipcode, "#####'-'%%%%", "Zip Code" },
  318.    { 13, 31, 13, 40, FLD_NWR, 10, H_NONE, Key_A_P, NULL, NULL, NULL,
  319.       phone, "'('###') '###'-'####", "Phone" },
  320.    { 15, 3, 15, 16, FLD_MIX, 11, H_COMPILER, Key_A_O, NULL, PickCompiler,
  321.       NULL, compiler, "***************", "Compiler" },
  322.    { 15, 37, 15, 46, FLD_CUR, 12, H_AMOUNT, Key_A_M, NULL, NULL, NULL,
  323.       amtenc, "$$$$.$$", "Amount" },
  324.    { 17, 3, 17, 16, FLD_NUL, 13, H_NONE, Key_A_N, NULL, NULL, NULL,
  325.       comments, "***********************************\n"
  326.      "***********************************", "Comments" },
  327. };
  328.  
  329. ChrP sDstrmatch[] =           /* sample source text for strings demo    */
  330. {
  331.    "VOID CTYP  Dstrmatch(NOARG)\n",
  332.    "{\n",
  333.    "  ChrP strings[] = { \"Hello\", \"There\", \"Computer\", \"World\", "
  334.       "NULL };\n",
  335.    "  ChrP str1 = \"xhelpx\";\n",
  336.    "  IntT i = 0;\n",
  337.    "\n",
  338.    "  while(strings[i] != NULL)\n",
  339.    "  {\n",
  340.    "    Wputf(\" <%s> vs. <%s> = <%d>\\n\", \n",
  341.    "      str1, strings[i], strmatch(str1, strings[i]));\n",
  342.    "    i++;\n",
  343.    "  }\n",
  344.    "\n",
  345.    "  Wputf(\" <%s> best matches <%s>\\n\", str1, strbmatch(str1, string"
  346.       "s));\n",
  347.    "}\n",
  348.    NULL,
  349. };
  350.  
  351. ChrP sDstrtrim[] =
  352. {
  353.    "VOID CTYP  Dstrtrim(NOARG)\n",
  354.    "{\n",
  355.    "  ChrP str1 = \"     Hello, world     \";\n",
  356.    "  ChrT str2[25];\n",
  357.    "\n",
  358.    "  strcpy(str2, str1);\n",
  359.    "  strltrim(str2);\n",
  360.    "  Wputf(BefAft, str1, str2);\n",
  361.    "\n",
  362.    "  strcpy(str2, str1);\n",
  363.    "  strrtrim(str2);      /* identical to strtrim() */\n",
  364.    "  Wputf(BefAft, str1, str2);\n",
  365.    "\n",
  366.    "  strcpy(str2, str1);\n",
  367.    "  strbtrim(str2);\n",
  368.    "  Wputf(BefAft, str1, str2);\n",
  369.    "\n",
  370.    "}\n",
  371.    NULL,
  372. };
  373.  
  374. ChrP sDstrchg[] =
  375. {
  376.    "VOID CTYP  Dstrchg(NOARG)\n",
  377.    "{ ChrP str1 = \"HelLo, worLd\";\n",
  378.    "  ChrP str2 = \"Hello, world\";\n",
  379.    "  ChrP str3 = \"xxxhElLoyyyHElLOzzz\";\n",
  380.    "  ChrP str4 = \"xxxhElloyyyhellozzz\";\n",
  381.    "  ChrT str5[30];\n",
  382.    "\n",
  383.    "  strcpy(str5, str1);\n",
  384.    "  strchg(str5, 'l', 'z');\n",
  385.    "  Wputf(BefAft, str1, str5);\n",
  386.    "\n",
  387.    "  strcpy(str5, str2);\n",
  388.    "  strichg(str5, 'l', 'z');\n",
  389.    "  Wputf(BefAft, str2, str5);\n",
  390.    "\n",
  391.    "  strcpy(str5, str3);\n",
  392.    "  strischg(str5, \"HeLlO\", \"goodbye\");\n",
  393.    "  Wputf(BefAft, str3, str5);\n",
  394.    "\n",
  395.    "  strcpy(str5, str4);\n",
  396.    "  strschg(str5,\"hello\",\"goodbye\");\n",
  397.    "  Wputf(BefAft, str4, str5);\n",
  398.    "}\n",
  399.    NULL,
  400. };
  401.  
  402. ChrP sDstrchksum[] =
  403. {
  404.    "VOID CTYP  Dstrchksum(NOARG)\n",
  405.    "{\n",
  406.    "  ChrP str1 = \"Hello, world\";\n",
  407.    "\n",
  408.    "  Wputf(\"Checksum is %lu, I-Checksum is %lu\\n\",\n",
  409.    "    strchksum(str1), strichksum(str1));\n",
  410.    "}\n",
  411.    NULL,
  412. };
  413.  
  414. ChrP sDstrdel[] =
  415. {
  416.    "VOID CTYP  Dstrdel(NOARG)\n",
  417.    "{\n",
  418.    "  ChrP str1 = \"XyZHello, xYzworldXyZxYz\";\n",
  419.    "  ChrT str2[35];\n",
  420.    "  \n",
  421.    "  strcpy(str2, str1);\n",
  422.    "  strdel(\"xYz\", str2);\n",
  423.    "  Wputf(BefAft, str1, str2);\n",
  424.    "  strcpy(str2, str1);\n",
  425.    "  strdela(\"xYz\", str2);\n",
  426.    "  Wputf(BefAft, str1, str2);\n",
  427.    "  strcpy(str2, str1);\n",
  428.    "  stridel(\"xYz\", str2);\n",
  429.    "  Wputf(BefAft, str1, str2);\n",
  430.    "  strcpy(str2, str1);\n",
  431.    "  stridela(\"xYz\", str2);\n",
  432.    "  Wputf(BefAft, str1, str2);\n",
  433.    "  strcpy(str1, str2);\n",
  434.    "  strins(\"xYz\", str2, 4);\n",
  435.    "  Wputf(BefAft, str1, str2);\n",
  436.    "}\n",
  437.    NULL,
  438. };
  439.  
  440. ChrP sDstrinc[] =
  441. {
  442.    "VOID CTYP  Dstrinc(NOARG)\n",
  443.    "{\n",
  444.    "  ChrP str1 = \"Hello1HELLO2HeLlO3hElLo\";\n",
  445.    "  ChrP str2 = \"hello\";\n",
  446.    "\n",
  447.    "  Wputf(\"str2 is %sincluded in str1\\n\",\n",
  448.    "    ( (strinc(str2,str1) == NULL) ? \n",
  449.    "    \"not \" : \"\"));\n",
  450.    "\n",
  451.    "  Wputf(\"str2 is %sincluded in str1\\n\",\n",
  452.    "    ( (striinc(str2,str1) == NULL) ? \n",
  453.    "    \"not \" : \"\"));\n",
  454.    "\n",
  455.    "  Wputf(\"There are %d occurrences of '%c' in str1\\n\",\n",
  456.    "            strocc(str1, 'l'), 'l');\n",
  457.    "  Wputf(\"There are %d occurrences of '%c' in str1\\n\",\n",
  458.    "            striocc(str1, 'l'), 'l');\n",
  459.    "\n",
  460.    "  Wputf(\"str2 occurs in str1 %d times\\n\",\n",
  461.    "    strsocc(str2, str1));\n",
  462.    "  Wputf(\"str2 occurs in str1 %d times\\n\",\n",
  463.    "    strisocc(str2, str1));\n",
  464.    "}\n",
  465.    NULL,
  466. };
  467.  
  468. ChrP sDstrsrep[] =
  469. {
  470.    "VOID CTYP  Dstrsrep(NOARG)\n",
  471.    "{\n",
  472.    "  ChrP str1 = \"This is a big string\";\n",
  473.    "  ChrT str2[25];\n",
  474.    "\n",
  475.    "  strcpy(str2, str1);\n",
  476.    "  strsrep(str2, \"str\", \"th\");\n",
  477.    "  Wputf(BefAft, str1, str2);\n",
  478.    "\n",
  479.    "  strcpy(str2, str1);\n",
  480.    "  strisrep(str2, \"str\", \"th\");\n",
  481.    "  Wputf(BefAft, str1, str2);\n",
  482.    "\n",
  483.    "}\n",
  484.    NULL,
  485. };
  486.  
  487. ChrP sDstrmid[] =
  488. {
  489.    "VOID CTYP  Dstrmid(NOARG)\n",
  490.    "{\n",
  491.    "  ChrP p;\n",
  492.    "  ChrP str = \"Hello, world\";\n",
  493.    "\n",
  494.    "  Wputf(\"    %s\\n\", p = strmid(str, 5, 5));\n",
  495.    "  free(p);\n",
  496.    "\n",
  497.    "  Wputf(\"    %s\\n\", p = strleft(str, 5));\n",
  498.    "  free(p);\n",
  499.    "\n",
  500.    "  Wputf(\"    %s\\n\", p = strright(str, 5));\n",
  501.    "  free(p);\n",
  502.    "  \n",
  503.    "}\n",
  504.    NULL,
  505. };
  506.  
  507. ChrP sDstrljust[] =
  508. {
  509.    "VOID CTYP  Dstrljust(NOARG)\n",
  510.    "{ ChrP str1 = \"     Hello, world     \";\n",
  511.    "  ChrP str2 = \"Hello, world\";\n",
  512.    "  ChrT str3[25];\n",
  513.    "  strcpy(str3, str1);\n",
  514.    "  strljust(str3);\n",
  515.    "  Wputf(BefAft, str1, str3);\n",
  516.    "  strcpy(str3, str1);\n",
  517.    "  strrjust(str3);\n",
  518.    "  Wputf(BefAft, str1, str3);\n",
  519.    "  strcpy(str3, str2);\n",
  520.    "  strrol(str3, 3);\n",
  521.    "  Wputf(BefAft, str2, str3);\n",
  522.    "  strcpy(str3, str2);\n",
  523.    "  strror(str3, 3);\n",
  524.    "  Wputf(BefAft, str2, str3);\n",
  525.    "  strcpy(str3, str2);\n",
  526.    "  strshl(str3, 3);\n",
  527.    "  Wputf(BefAft, str2, str3);\n",
  528.    "  strcpy(str3, str2);\n",
  529.    "  strshr(str3, 3);\n",
  530.    "  Wputf(BefAft, str2, str3);\n",
  531.    "}\n",
  532.    NULL,
  533. };
  534.  
  535. ChrP sDstrblank[] =
  536. {
  537.    "VOID CTYP  Dstrblank(NOARG)\n",
  538.    "{ ChrP str1 = \"  Hello  \";\n",
  539.    "  ChrP str2 = \" \\n  \\t \\r \";\n",
  540.    "  ChrP str3 = \"Hello, world\";\n",
  541.    "  ChrP str4 = \"hElLo, wOrLd\";\n",
  542.    "  ChrT str5[20];\n",
  543.    "  Wputf(\" str1 is %sblank\\n\", strblank(str1) ? \"\" : \"not \");\n",
  544.    "  Wputf(\" str2 is %sblank\\n\", strblank(str2) ? \"\" : \"not \");\n",
  545.    "  Wputf(\" Before:    <%s>\\n\", str3);\n",
  546.    "  strcode(str3, \"34&*#Mdq\");\n",
  547.    "  Wputf(\" Encrypted: <%s>\\n\", str3);\n",
  548.    "  strcode(str3, \"34&*#Mdq\");\n",
  549.    "  Wputf(\" Decrypted: <%s>\\n\", str3);\n",
  550.    "  strcpy(str5, str3);\n",
  551.    "  Wputf(\" Before:  <%s>\\n\", str5);\n",
  552.    "  strsetsz(str5, 20);\n",
  553.    "  Wputf(\" Len=20:  <%s>\\n\", str5);\n",
  554.    "  strsetsz(str5, 5);\n",
  555.    "  Wputf(\" Len=5:   <%s>\\n\", str5);\n",
  556.    "  strcpy(str5, str4);\n",
  557.    "  struplow(str5);\n",
  558.    "  Wputf(BefAft, str4, str5);\n",
  559.    "}\n",
  560.    NULL,
  561. };
  562.  
  563. ChrP Dstrings[] =                      /* more text for strings demo    */
  564. {  "Hello", "There", "Computer", "World", NULL };
  565.  
  566.  
  567. ChrP Sdemo1[] =                        /* strings demo menu titles      */
  568. {
  569.    "Trimming", "Changing", "Checksum", "Delete/Insert",
  570.    "Inclusion", "Replacement", "Substrings", "Justification",
  571.    "Matching", "Miscellaneous", "Exit", NULL
  572. };
  573.  
  574. TYP struct _StrDmo
  575. {
  576.    ChrP *Dsp;                          /* sample source text array      */
  577.    VfvCP Fun;                          /* demo function                 */
  578.    IntT Wrws;                          /* coords for result window      */
  579.    IntT Wcls;                          /* "      "   "      "           */
  580. }   STRDMO;
  581.  
  582. STRDMO Sdemo[] =                       /* string demo control           */
  583. {
  584.    {  sDstrtrim,   Dstrtrim,    9, 35  },
  585.    {  sDstrchg,    Dstrchg,    11, 36  },
  586.    {  sDstrchksum, Dstrchksum,  5, 19  },
  587.    {  sDstrdel,    Dstrdel,    13, 37  },
  588.    {  sDstrinc,    Dstrinc,    11, 32  },
  589.    {  sDstrsrep,   Dstrsrep,    7, 33  },
  590.    {  sDstrmid,    Dstrmid,     7, 15  },
  591.    {  sDstrljust,  Dstrljust,  15, 35  },
  592.    {  sDstrmatch,  Dstrmatch,   8, 32  },
  593.    {  sDstrblank,  Dstrblank,  13, 34  },
  594. };
  595.  
  596. ChrP LinArr[] =            /* screen lines table -- used by menu demo   */
  597. {
  598.    "25 Lines", "43 Lines", "50 Lines", NULL
  599. };
  600.  
  601. ChrP UvArr[] = /* Ultravision screen modes table -- used by menu demo   */
  602. {
  603.    "80x25",                   "80x43 EGA, 80x50 VGA",
  604.    "80x34 EGA, 80x36 VGA",    "80x60 EGA, 80x63 VGA",
  605.    "94x25",                   "94x43 EGA, 94x50 VGA",
  606.    "94x36",                   "94x63",
  607.    "108x25",                  "108x43 EGA, 108x50 VGA",
  608.    "108x34 EGA, 108x36 VGA",  "108x60 EGA, 108x63 VGA",
  609.    "120x25",                  "120x43 EGA, 120x50 VGA",
  610.    "120x36", "120x63",        "132x25", "132x44, 132x50 SuperVGA",
  611.    "132x36", "132x60",        NULL
  612. };
  613.  
  614.  
  615. IntT UvMode[] =                        /* Ultravision mode numbers      */
  616. {
  617.    0x11, 0x12, 0x13, 0x14, 0x19, 0x1A, 0x1B, 0x1C,
  618.    0x21, 0x22, 0x23, 0x24, 0x31, 0x32, 0x39, 0x3A,
  619.    0x33, 0x34, 0x3B, 0x3C, 0
  620. };
  621.  
  622.                                        /* used by menu demo             */
  623. LCL ChrT Rmargin[] = "Right margin     72";
  624. LCL ChrT Lmargin[] = "Left margin       0";
  625.  
  626. TYP struct _DoItm
  627. {
  628.    IntT wr;                            /* MnuItm() row                  */
  629.    IntT wc;                            /* "        column               */
  630.    ChrP ps;                            /* "        prompt               */
  631.    IntT sc;                            /* "        selection character  */
  632.    TagT id;                            /* "        id tag               */
  633.    IntT fm;                            /* "        feature mask         */
  634.    VfvCP sf;                           /* "        selection function   */
  635.    WrdT hk;                            /* "        hot key              */
  636.    TagT he;                            /* "        help key             */
  637. }   DOITM;
  638.  
  639. DOITM FileMnu[] =                /* menu demo -- "File" pulldown menu   */
  640. {
  641.    { 0, 0, "Load",          'L', 20, 0, DoNothing, 0, H_LOAD },
  642.    { 1, 0, "Save",          'S', 21, 0, DoNothing, 0, H_SAVE },
  643.    { 2, 0, "Rename",        'R', 22, 0, DoNothing, 0, H_RENAME },
  644.    { 3, 0, "New",           'N', 23, 0, DoNothing, 0, H_NEW },
  645.    { 4, 0, "Directory  F5", 'D', 24, 0, Directory, Key_F5, H_DIRECTORY },
  646.    { 5, 0, "Execute    F6", 'E', 25, 0, Execute,   Key_F6, H_EXECUTE },
  647.    { 6, 0, "OS Shell   F7", 'O', 26, ITM_BEF, OsShell, Key_F7, H_OSSHELL },
  648.    { 7, 0, "Quit",          'Q', 27, ITM_ALL, NULL, 0, H_QUIT },
  649. };
  650.  
  651. DOITM EditMnu[] =                /* menu demo -- "Edit" pulldown menu   */
  652. {
  653.    { 0, 0, "Cut",         'C', 29, 0,       DoNothing,   0, H_NONE },
  654.    { 1, 0, "Paste",       'P', 30, ITM_NSL, DoNothing,   0, H_NONE },
  655.    { 2, 0, "cOpy",        'O', 31, ITM_NSL, DoNothing,   0, H_NONE },
  656.    { 3, 0, "block Begin", 'B', 32, 0,       ToggleBlock, 0, H_NONE },
  657.    { 4, 0, "block End",   'E', 33, ITM_NSL, ToggleBlock, 0, H_NONE },
  658.    { 5, 0, "Insert line", 'I', 34, 0,       DoNothing,   0, H_NONE },
  659.    { 6, 0, "Delete line", 'D', 35, 0,       DoNothing,   0, H_NONE },
  660. };
  661.  
  662. DOITM DefMnu[] =              /* menu demo -- "Defaults" pulldown menu  */
  663. {
  664.    { 0, 0, Lmargin,               'L', 37, ITM_ALL, RMargin, 0, H_NONE },
  665.    { 1, 0, Rmargin,               'R', 38, ITM_ALL, RMargin, 0, H_NONE },
  666.    { 2, 0, "Tab width         4", 'T', 39, 0, DoNothing, 0, H_NONE },
  667.    { 4, 0, "tab eXpansion   yes", 'X', 40, 0, ToggleYN,  0, H_NONE },
  668.    { 5, 0, "Insert mode     yes", 'I', 41, 0, ToggleYN,  0, H_NONE },
  669.    { 6, 0, "iNdent mode     yes", 'N', 42, 0, ToggleYN,  0, H_NONE },
  670.    { 7, 0, "Word wrap mode   no", 'W', 43, 0, ToggleYN,  0, H_NONE },
  671.    { 9, 0, "Save defaults",       'S', 44, 0, DoNothing, 0, H_NONE },
  672. };
  673.  
  674. DOITM OptMnu[] =              /* menu demo -- "Options" pulldown menu   */
  675. {
  676.    { 0, 0, "screen siZe",        'Z', 47, ITM_ALL, ChangeSize, 0, H_NONE},
  677.    { 1, 0, "Backup files   yes", 'B', 48, 0, ToggleYN,  0, H_NONE },
  678.    { 2, 0, "bOxed display   no", 'O', 49, 0, ToggleYN,  0, H_NONE },
  679.    { 3, 0, "Load options",       'L', 50, 0, DoNothing, 0, H_NONE },
  680.    { 4, 0, "Save options",       'S', 51, 0, DoNothing, 0, H_NONE },
  681. };
  682.  
  683. DOITM MainMnu[] =             /* Main Menu Selection Itemns             */
  684. {
  685.    { 0, 0, "Menu System",      'M', 1, 0, MenuDemo,   0, H_MENUING },
  686.    { 1, 0, "Entry System",     'E', 2, 0, EntryDemo,  0, H_DATAENTRY },
  687.    { 2, 0, "Selection System", 'S', 3, 0, SelectDemo, 0, H_LISTPICK },
  688.    { 3, 0, "Window System",    'W', 4, 0, WinDemo,    0, H_WINDOWING },
  689.    { 4, 0, "Input System",     'I', 5, 0, InputDemo,  0, H_INPUT },
  690.    { 5, 0, "Strings System",   't', 6, 0, StringDemo, 0, H_STRINGS },
  691.    { 6, 0, "Information",      'n', 7, 0, TcxlInfo,   0, H_NONE },
  692.    { 7, 0, "Exit demo",        'x', 8, 0, NULL,       0, H_NONE },
  693. };
  694.  
  695. IntT Siz1[] =                          /* used in window demo           */
  696. {  19, 19, 24, 24, 24, 19  };
  697. IntT Siz2[] =
  698. {  60, 75, 75, 60, 45, 45  };
  699. IntT Siz3[] =
  700. {   0, 10,  6,  1, 11,  2  };
  701. IntT Siz4[] =
  702. {   0,  4, 19, 13, 35, 39  };
  703.  
  704. ChrP Wdm =                             /* used in window demo           */
  705.    "Now that you've had a chance to see the various features "
  706.    "of the TCXL Window System, we'd like to give you a chance "
  707.    "to see the SAME demonstation again . . . this "
  708.    "time, without the built-in delays.  Press any key to "
  709.    "start this one running.  Watch out!";
  710.  
  711. ChrP Edemo[] = {                       /* used in Editor demo           */
  712.    "This is a sample editor interface to demonstrate how TCXL's menuing ",
  713.    "functions can be used to create a pull-down menu system.  Use the ",
  714.    "arrow keys to move the selection bar around and use the [Esc] key to ",
  715.    "back up to the previous menu.  Pressing [F1] will bring up ",
  716.    "context-sensitive help.  Select [Q]uit from any menu to exit the ",
  717.    "Menu Demonstration.  Be sure to try some of the menu options in ",
  718.    "the pull-down menus.  In particular, you might try to change ",
  719.    "the left and right margins under the <D>efault option, or to ",
  720.    "adjust the screen size if you have an EGA/VGA, or use Ultravision.",
  721.    NULL
  722.    };
  723.  
  724. /*------------------------[ Program entry point ]-----------------------*/
  725.  
  726. IntT CDC main(IntT argc, ChrP argv[])
  727. {
  728.    Initialize();
  729.    ParseCmdLine(argc, argv);
  730.    OpenBkgrnd();
  731.    MainMenu();
  732.    NormalExit();
  733.    return(0);
  734. }
  735.  
  736. /*----------------------------------------------------------------------*/
  737. /* Initializes TCXL's video, mouse, keyboard, and help systems.         */
  738.  
  739. VOID  CTYP  Initialize(NOARG)
  740. {
  741.    TcxlInit();
  742.    KextOff();                          /* no extended key BIOS          */
  743.    VcurGet(rc);
  744.    savescrn = FarVsave(LGREY|_BLACK);
  745.    if(MouInit)
  746.       MShome();
  747.                         /* attach [Alt-X] to the ConfirmQuit() function */
  748.    KbndSet(Key_A_X, ConfirmQuit, 0);
  749.  
  750.                         /* initialize help system, help key = [F1]      */
  751.    HlpDef("TCXLDEMO.HLP", Key_F1, YELLOW|_RED, LRED|_RED, WHITE|_RED,
  752.          RED|_LGREY, PreHelp);
  753.  
  754. }
  755.  
  756. /*----------------------------------------------------------------------*/
  757. /* Parses the command line for valid invocation switches. If any valid  */
  758. /* switches are found, the appropriate video variable will be set.  If  */
  759. /* any invalid parameters are found, a syntax message is displayed.     */
  760.  
  761. VOID  CTYP  ParseCmdLine(IntT ac, ChrP av[])
  762. {
  763.    REG IntT    i, j;
  764.    ChrP        p;
  765.  
  766.    for(i = 1; i < ac; i++)
  767.    {
  768.       p = av[i];
  769.       if(*p == '-' || *p == '/')
  770.       {
  771.          for(j = 1; *(p + j); j++)
  772.          {
  773.             switch(tolower(*(p + j)))
  774.             {
  775.                case 'c':
  776.                   VidParm(VP_CGA);
  777.                   break;
  778.  
  779.                case 'b':
  780.                   VidParm(VP_BIO);
  781.                   break;
  782.  
  783.                case 'm':
  784.                   VidParm(VP_MON);
  785.                   break;
  786.  
  787.                default:
  788.                   ErrorExit(2);
  789.             }
  790.          }
  791.       }
  792.       else
  793.          ErrorExit(2);
  794.    }
  795. }
  796.  
  797. /*----------------------------------------------------------------------*/
  798. /* Draws main background window, program title window and system        */
  799. /* information window in preparation for main menu.                     */
  800.  
  801. VOID  CTYP  OpenBkgrnd(NOARG)
  802. {
  803.    ChrT  str[90];
  804.  
  805.    if(!Wopen(0, 0, VidDep - 2, VidWid - 1, 5, 0, LGREEN|_GREEN))
  806.       ErrorExit(1);
  807.  
  808.    if(!WpopUp(CNT_HOR, VidDep - 8, 0, VidDep - 3, 60, 0, LGREY|_RED,
  809.          LGREY|_RED))
  810.       ErrorExit(1);
  811.  
  812.    AddShadow();
  813.    sprintf(str, "DPMI Status: %s   VCPI Status: %s\n",
  814.       (MemDPMI ? "INSTALLED" : "NOT INSTALLED"),
  815.       (MemVCPI ? "INSTALLED" : "NOT INSTALLED"));
  816.    WputCen(str);
  817.  
  818.    sprintf(str, "Total EMS: %dK   Free EMS: %dK\n",
  819.       MemEtot * 16, MemEfre * 16);
  820.    WputCen(str);
  821.  
  822.    sprintf(str, "Free XMS: %dK   HMA is %s\n", MemXtot,
  823.       (MemHfre ? "AVAILABLE" : "IN USE"));
  824.    WputCen(str);
  825.  
  826.    sprintf(str, "Ultravision is %s   Screen Size is %dx%d",
  827.       (TcxlUv ? "INSTALLED" : "NOT INSTALLED"), VidWid, VidDep);
  828.    WputCen(str);
  829.  
  830.    WsetFil('\260');
  831.    Wopen(VidDep - 1, 0, VidDep - 1, VidWid - 1, 5, 0, LGREY|_RED);
  832.    Wprts(0, 1, LGREY|_RED, "[F1]=Help");
  833.    WprtCen(0, LGREY|_RED, "Select demonstration to view.");
  834.    Wprtrj(0, VidWid - 2, LGREY|_RED, "[Alt-X]=Quit");
  835.    WsetFil(' ');
  836.    if(!WpopUp(CNT_HOR, 0, 12, 4, 67, 0, LRED|_MAGENTA, LRED|_MAGENTA))
  837.       ErrorExit(1);
  838.  
  839.    AddShadow();
  840.    WprtCen(0, WHITE|_MAGENTA,
  841.       "Welcome to the TCXL Demonstration Program!");
  842.    WprtCen(2, LCYAN|_MAGENTA,
  843.       "Copyright (c) 1987-1990, Innovative Data Concepts");
  844. }
  845.  
  846. /*----------------------------------------------------------------------*/
  847. /* Set up and run the main menu, from which all else happens. But first,*/
  848. /* push global help category onto help stack, so when [F1] is pressed   */
  849. /* while selection bar is on an item without help, the global help      */
  850. /* category will be used.                                               */
  851.  
  852. VOID  CTYP  MainMenu(NOARG)
  853. {
  854.    IntT i;
  855.  
  856.    LeftRow = ((VidDep - 1) / 2) - 6;   /* set up display coordinates    */
  857.    RightRow = LeftRow + 9;
  858.    LeftCol = ((VidWid - 1) / 2) - 9;
  859.    RightCol = LeftCol + 19;
  860.  
  861.    HlpPush(H_GLOBAL);                  /* push global help catagory     */
  862.  
  863.    MnuBeg(LeftRow, LeftCol, RightRow,  /* define the main menu          */
  864.       RightCol, 0, LBLUE|_BLUE, LBLUE|_BLUE, PreMenu1);
  865.  
  866.    for(i = 0; i < 8; i++)
  867.       MnuItm(MainMnu[i].wr, MainMnu[i].wc, MainMnu[i].ps,
  868.          MainMnu[i].sc, MainMnu[i].id, MainMnu[i].fm, MainMnu[i].sf,
  869.          MainMnu[i].hk, MainMnu[i].he);
  870.  
  871.    MnuEnd(1, MNU_VER, 19, 1, LCYAN|_BLUE, WHITE|_BLUE, 0, BLUE|_LGREY);
  872.  
  873.    if(MnuShow() == -1)                 /* process the menu              */
  874.       if(TcxlErr > W_ESCPRESS)
  875.          ErrorExit(1);
  876.  
  877.    HlpDrop();                          /* pop help category off stack   */
  878. }
  879.  
  880. /*----------------------------------------------------------------------*/
  881. /* The menu demo, a simulated editor interface.                         */
  882.  
  883. VOID  CTYP  MenuDemo(NOARG)
  884. {
  885.    IntT     s, st, i;
  886.    IntT     Lines;
  887.    VcelFP   VidArea;
  888.  
  889.    KbndIdle(UpdateClock);              /* start clock display           */
  890.    HlpPush(H_PULLDOWN);                /* push help category            */
  891.  
  892.    if(VuvAct)                          /* draw editor display           */
  893.       Lines = _VuvGet();
  894.    else
  895.       Lines = VidDep;
  896.    cvtic(&Rmargin[16], VidWid - 8, 3);
  897.    VidArea = FarVsave(LGREY|_BLACK);
  898.    st = VcurHid(-1);
  899. redraw:
  900.    if(atoi(&Rmargin[16]) > VidWid - 3)
  901.       cvtic(&Rmargin[16], VidWid - 8, 3);
  902.    DrawEditor(atoi(&Lmargin[16]), atoi(&Rmargin[16]));
  903.  
  904.    MnuBeg(1, 1, 1, VidWid - 2, 5,      /* start the menu                */
  905.       CYAN, CYAN|_BLUE, NULL);
  906.  
  907.    MnuItm(0, 2, "File", 'F', 19,       /* define first item,            */
  908.       ITM_PUL, NULL, 0, H_FILE);       /* a pulldown menu               */
  909.    MnuBeg(2, 1, 11, 17, 0, LGREY|_BLUE, _BLUE, NULL);
  910.    for(i = 0; i < 8; i++)
  911.       MnuItm(FileMnu[i].wr, FileMnu[i].wc, FileMnu[i].ps,
  912.          FileMnu[i].sc, FileMnu[i].id, FileMnu[i].fm, FileMnu[i].sf,
  913.          FileMnu[i].hk, FileMnu[i].he);
  914.    ItmFun(QuitWindow, QuitWindow);
  915.    MnuEnd(20, MNU_PUL|MNU_SAV, 15, 1, YELLOW|_BLUE, LCYAN|_BLUE, 0,
  916.       YELLOW|_MAGENTA);
  917.  
  918.    MnuItm(0, 15, "Editing", 'E', 28,   /* second item, also a pulldown  */
  919.       ITM_PUL, NULL, 0, H_EDITING);
  920.    MnuBeg(2, 14, 10, 28, 0, LGREY|_BLUE, _BLUE, NULL);
  921.    for(i = 0; i < 7; i++)
  922.       MnuItm(EditMnu[i].wr, EditMnu[i].wc, EditMnu[i].ps,
  923.          EditMnu[i].sc, EditMnu[i].id, EditMnu[i].fm, EditMnu[i].sf,
  924.          EditMnu[i].hk, EditMnu[i].he);
  925.    MnuEnd(29, MNU_PUL|MNU_SAV, 13, 1, YELLOW|_BLUE, LCYAN|_BLUE,
  926.       CYAN|_BLUE, YELLOW|_MAGENTA);
  927.  
  928.    MnuItm(0, 31, "Defaults", 'D', 36,  /* third item, also a pulldown   */
  929.       ITM_PUL, NULL, 0, H_DEFAULTS);
  930.    MnuBeg(2, 30, 13, 52, 0, LGREY|_BLUE, _BLUE, SetupMenu);
  931.    for(i = 0; i < 8; i++)
  932.       MnuItm(DefMnu[i].wr, DefMnu[i].wc, DefMnu[i].ps, DefMnu[i].sc,
  933.          DefMnu[i].id, DefMnu[i].fm, DefMnu[i].sf, DefMnu[i].hk,
  934.          DefMnu[i].he);
  935.    MnuEnd(37, MNU_PUL|MNU_SAV, 21, 1, YELLOW|_BLUE, LCYAN|_BLUE, 0,
  936.       YELLOW|_MAGENTA);
  937.  
  938.    MnuItm(0, 47, "Run", 'R', 45, 0,    /* fourth item, a popup menu     */
  939.       PopupDemo, 0, H_RUN);
  940.  
  941.    MnuItm(0, 59, "Options", 'O', 46,   /* fifth item, another pulldown  */
  942.       ITM_PUL, NULL, 0, H_OPTIONS);
  943.    MnuBeg(2, 56, 8, 77, 0, LGREY|_BLUE, _BLUE, NULL);
  944.    for(i = 0; i < 5; i++)
  945.       MnuItm(OptMnu[i].wr, OptMnu[i].wc, OptMnu[i].ps, OptMnu[i].sc,
  946.          OptMnu[i].id, OptMnu[i].fm, OptMnu[i].sf, OptMnu[i].hk,
  947.          OptMnu[i].he);
  948.    MnuEnd(47, MNU_PUL|MNU_SAV, 20, 1, YELLOW|_BLUE, LCYAN|_BLUE, 0,
  949.       YELLOW|_MAGENTA);
  950.  
  951.    MnuItm(0, 73, "Quit", 'Q', 52,      /* fifth item, a pulldown with   */
  952.       ITM_PUL, NULL, 0, H_NONE);       /* an automatic popup window     */
  953.    ItmFun(QuitWindow, QuitWindow);
  954.    MnuBeg(2, 60, 7, 78, 0, LGREY|_BLUE, _BLUE, DispSureMsg);
  955.    MnuItm(2, 0, "No", 'N', 53, ITM_AFT, NULL, 0, H_NONE);
  956.    MnuItm(3, 0, "Yes", 'Y', 54, ITM_ALL, NULL, 0, H_NONE);
  957.    MnuEnd(53, MNU_PUL, 17, 7, YELLOW|_BLUE, LCYAN|_BLUE, WHITE|_BLUE,
  958.       YELLOW|_MAGENTA);
  959.  
  960.    MnuEnd(19, MNU_HOR, 0, 0,           /* define the end of the menu    */
  961.       YELLOW|_BLUE, LCYAN|_BLUE, 0, YELLOW|_MAGENTA);
  962.  
  963.    s = MnuShow();                      /* process the menu              */
  964.    if(s == -1 && TcxlErr > W_ESCPRESS)
  965.       ErrorExit(1);
  966.  
  967.    Wclose();
  968.    Wclose();
  969.    if((s == 37) || (s == 38) || (s == 47) || (s >= 100))
  970.       goto redraw;
  971.    if(VuvAct)
  972.    {
  973.       if(Lines != _VuvGet())
  974.          _VuvSet(Lines);
  975.    }
  976.    else
  977.    {
  978.       if(Lines != VidDep)
  979.          VsetLin(Lines);
  980.    }
  981.    VcurHid(st);
  982.    FarVrestore(VidArea);
  983.    KbndIdle(NULL);
  984.    HlpDrop();
  985.    MoveBarDn();
  986. }
  987.  
  988. /*----------------------------------------------------------------------*/
  989. /* Entry demo.  A form consisting of a group of entry fields is defined.*/
  990.  
  991. VOID  CTYP  EntryDemo(NOARG)
  992. {
  993.    REG IntT    c, m = 0, p = 0, i;
  994.    KeyT        k;
  995.    VcelFP      s;
  996.  
  997.    s = FarVsave(LGREY|_BLUE);
  998.  
  999.    if(!WpopUp(CNT_CNT, 2, 8, 23, 70, 1, LCYAN|_BLUE, LCYAN|_BLUE))
  1000.       ErrorExit(1);
  1001.  
  1002.    AddShadow();
  1003.    Wtitle("[ TCXL Order Form ]", TTL_LFT, LCYAN|_BLUE);
  1004.    Wmessage("[ $50 Plus $3 S&H ]", BRD_TOP, 42, LCYAN|_BLUE);
  1005.    Wmessage(" [F10]=Finished ",    BRD_BOT,  5, LCYAN|_BLUE);
  1006.    Wmessage(" [F9]=Today ",        BRD_BOT, 25, LCYAN|_BLUE);
  1007.    Wmessage(" [Esc]=Abort ",       BRD_BOT, 45, LCYAN|_BLUE);
  1008.    HlpPush(H_EDITKEYS);
  1009.    do
  1010.    {
  1011.       EntDef(BLUE|_LGREY, WHITE|_LGREY);
  1012.       for(i = 0; i < DEMO_CNT; i++)
  1013.       {
  1014.          Wprts(DmFld[i].Prow, DmFld[i].Pcol, WHITE|_BLUE,
  1015.               DmFld[i].Prompt);
  1016.          EntFld(DmFld[i].Frow, DmFld[i].Fcol, DmFld[i].Field,
  1017.                DmFld[i].FmtStr, DmFld[i].Fflg, DmFld[i].Ftag, m,
  1018.                DmFld[i].Val, DmFld[i].Htag);
  1019.          FldFun(DmFld[i].FunBef, DmFld[i].FunAft);
  1020.          FldKey(DmFld[i].Fkey);
  1021.       }
  1022.       EntKey(GetKey, &k);              /* alternate kbd get function    */
  1023.  
  1024.       if(EntShow())           /* Mark end of form and process it. If    */
  1025.          break;               /* [Esc] was pressed, then don't bother   */
  1026.                               /* with the confirmation message.         */
  1027.       if(!WpopUp(CNT_CNT, 9, 20, 13, 64, 0, WHITE|_CYAN, WHITE|_CYAN))
  1028.          ErrorExit(1);
  1029.  
  1030.  
  1031.  
  1032.       if(k != Key_F10)        /* Test to see if [F10] was pressed. If   */
  1033.       {                       /* so, don't display confirmation message.*/
  1034.          AddShadow();
  1035.          Wputc('\n');         /* Display confirmation message           */
  1036.          WputCen("Is this information correct? \033A\076Y\b");
  1037.          KeyClear();
  1038.          c = KwGetYn('Y');
  1039.       }
  1040.       else
  1041.          c = 'Y';
  1042.       if(c == 'Y')
  1043.       {
  1044.          Wclear();
  1045.          Wputc('\n');
  1046.          WputCen("Would you like your order printed? \033A\076Y\b");
  1047.          KeyClear();
  1048.          p = KwGetYn('Y');
  1049.       }
  1050.       Wclose();
  1051.       if(p == 'Y')
  1052.          PrintOrder();
  1053.       m = 1;                  /* Change fld mode to "update"            */
  1054.    } while(c != 'Y');
  1055.    HlpDrop();
  1056.    Wclose();
  1057.    FarVrestore(s);
  1058.    VcurHid(0);
  1059.    MoveBarDn();
  1060. }
  1061.  
  1062. /*----------------------------------------------------------------------*/
  1063. /* Selection demo.  Demonstrates the string picker, the file picker,    */
  1064. /* and the in-place string selector functions.                          */
  1065.  
  1066. VOID  CTYP  SelectDemo(NOARG)
  1067. {
  1068.    REG VcelFP  s;
  1069.  
  1070.    s = FarVsave(LGREY|_BLUE);
  1071.    MSpush(MOU_FULL);
  1072.  
  1073.    if(!WpopUp(CNT_CNT, 5, 11, 17, 68, 3, LMAGENTA|_RED, LRED|_MAGENTA))
  1074.       ErrorExit(1);
  1075.  
  1076.    AddShadow();
  1077.    Wputf("\033R\001\033C\003Select a month =>\033R\001\033C\003");
  1078.    HlpSet(H_STRPICK);
  1079.    YouSelected(months[SelStr(LeftRow, 32, LeftRow + 5, -1, 0,
  1080.       LGREEN|_RED, LCYAN|_RED, RED|_LGREY, months, 0, PrePick1)]);
  1081.  
  1082.    Wputf("\033R\003\033C\003Now, select a file.\033R\003\033C\003");
  1083.    HlpSet(H_FILEPICK);
  1084.    YouSelected(SelFile(LeftRow, LeftCol - 18, LeftRow + 10,
  1085.       LeftCol + 39, 0, LCYAN|_RED, LGREY|_RED, RED|_LGREY, 1, "*.*",
  1086.       AddShadow));
  1087.  
  1088.    Wputf("\033R\005\033C\003Select a printer port:\033R\005\033C\003");
  1089.    VcurHid(1);
  1090.    YouSelected(prn_ports[SelTxt(5, 27, LMAGENTA|_MAGENTA, prn_ports, 0)]);
  1091.    VcurHid(0);
  1092.  
  1093.    HlpSet(H_PICKATTR);
  1094.    Wputf("\033R\007\033C\003Select a text attribute:\033R\007\033C\003");
  1095.    VcurHid(1);
  1096.    YouSelected(VatrTxt(SelAttr(LeftRow - 6, LeftCol - 21, 0, 0,
  1097.       TRUE, AddShadow)));
  1098.    VcurHid(0);
  1099.    Wclose();
  1100.    MSpop();
  1101.    FarVrestore(s);
  1102.    MoveBarDn();
  1103. }
  1104.  
  1105. /*----------------------------------------------------------------------*/
  1106. /* Window Demo.                                                         */
  1107.  
  1108. VOID  CTYP  WinDemo(NOARG)
  1109. {
  1110.    VcelFP   s;
  1111.  
  1112.    s = FarVsave(LGREY|_BLUE);
  1113.    MSpush(MOU_FULL);
  1114.    for(DemoFast = 0; DemoFast < 2; DemoFast++)
  1115.    {
  1116.       ScrollDemo();
  1117.       AttrDemo();
  1118.       BordDemo();
  1119.       TitleDemo();
  1120.       ResizeDemo();
  1121.       TLineDemo();
  1122.       MoveDemo();
  1123.       HideDemo();
  1124.       ActivDemo();
  1125.       CopyDemo();
  1126.       CloseWinDemo();
  1127.       if(!DemoFast)
  1128.       {
  1129.          WpopUp(CNT_CNT, 0, 0, 9, 35, 0, WHITE|_CYAN, YELLOW|_RED);
  1130.          Wputsw(Wdm);
  1131.          KeyWait();
  1132.       }
  1133.       else
  1134.       {
  1135.          WpopUp(CNT_CNT, 0, 0, 2, 25, 0, WHITE|_CYAN, YELLOW|_RED);
  1136.          WputCen("Fast enough for you?");
  1137.          KeyTime(54);
  1138.       }
  1139.       Wclose();
  1140.    }
  1141.    DemoFast = 0;
  1142.    MSpop();
  1143.    FarVrestore(s);
  1144.    KeyClear();
  1145.    MoveBarDn();
  1146. }
  1147.  
  1148. /*----------------------------------------------------------------------*/
  1149. /* Input demo.                                                          */
  1150.  
  1151. VOID  CTYP  InputDemo(NOARG)
  1152. {
  1153.    VcelFP   s;
  1154.    IntT     st;
  1155.  
  1156.    s = FarVsave(LGREY|_BLUE);
  1157.    st = VcurHid(-1);
  1158.    if(!WpopUp(CNT_CNT, 5, 21, 15, 58, 3, LGREEN|_MAGENTA,
  1159.          LGREEN|_MAGENTA))
  1160.       ErrorExit(1);
  1161.  
  1162.    Wtitle("[ Single-Line Input ]", TTL_CNT, LGREEN|_MAGENTA);
  1163.    HlpSet(H_DATAENTRY);
  1164.    AddShadow();
  1165.    RestoreCursor();
  1166.    if(KwGetFmt(phone, "'\n\n  Phone Number?    "
  1167.          "'!R--!'('!+!###!-!') '!+!###!-!'-'!+!####"))
  1168.       ConfirmQuit();
  1169.    RestoreCursor();
  1170.  
  1171.    if(KwGetFmt(ssan, "'\n\n  Soc Sec Number?  "
  1172.           "'!R-!<01234567>##!-!'-'!+!##!-!'-'!+!####"))
  1173.       ConfirmQuit();
  1174.    RestoreCursor();
  1175.  
  1176.    if(KwGetFmt(date, "\"\n\n  Today's Date?    "
  1177.           "\"!R-!<01>#!-!'/'!+!<0123>#!-!'/'!+!'19'##"))
  1178.       ConfirmQuit();
  1179.    Wclose();
  1180.    VcurHid(st);
  1181.    FarVrestore(s);
  1182.    KeyClear();
  1183.    MoveBarDn();
  1184. }
  1185.  
  1186. /*----------------------------------------------------------------------*/
  1187. /* Strings demo.                                                        */
  1188.  
  1189. VOID  CTYP  StringDemo(NOARG)
  1190. {
  1191.    VcelFP   s;
  1192.    IntT     st, Sel = 0, i;
  1193.  
  1194.    s = FarVsave(LGREY|_BLACK);
  1195.    MSpush(MOU_FULL);
  1196.    st = VcurHid(-1);
  1197.    LeftRow = ((VidDep - 1) / 2) - 6;
  1198.    RightRow = LeftRow + 12;
  1199.    LeftCol = ((VidWid - 1) / 2) - 9;
  1200.    RightCol = LeftCol + 16;
  1201.  
  1202.    for(;;)
  1203.    {
  1204.       Sel = SelStr(LeftRow, LeftCol, RightRow, RightCol, 1, LCYAN|_BLUE,
  1205.          LCYAN|_BLUE, YELLOW|_LGREY, Sdemo1, Sel, NULL);
  1206.       if((Sel >= 10) || (Sel < 0))
  1207.          break;
  1208.       if(!WpopUp(CNT_CNT, 0, 0, 24, VidWid - 1, 1, LCYAN|_BLUE,
  1209.             LCYAN|_BLUE))
  1210.          ErrorExit(1);
  1211.  
  1212.       Wtitle(Sdemo1[Sel], TTL_CNT, LCYAN|_BLUE);
  1213.       Wmessage(" [Press a Key to Continue ] ", BRD_BOT,
  1214.          ((VidWid - 1) / 2) - 15, LCYAN|_BLUE);
  1215.       i = 0;
  1216.       while(Sdemo[Sel].Dsp[i] != NULL)
  1217.          Wputs(Sdemo[Sel].Dsp[i++]);
  1218.       if(!Wopen(((VidDep - 25) / 2) + 1, VidWid - 1 - Sdemo[Sel].Wcls - 1,
  1219.             ((VidDep - 25) / 2) + 1 + Sdemo[Sel].Wrws, VidWid - 2, 0,
  1220.             WHITE|_RED, WHITE|_BLUE))
  1221.          ErrorExit(1);
  1222.       (*Sdemo[Sel].Fun)();
  1223.       PressAKey1(Sdemo[Sel].Wrws - 2, -1);
  1224.       Wclose();
  1225.       Wclose();
  1226.       Sel++;
  1227.    }
  1228.    VcurHid(st);
  1229.    MSpop();
  1230.    FarVrestore(s);
  1231.    KeyClear();
  1232.    MoveBarDn();
  1233. }
  1234.  
  1235. /*----------------------------------------------------------------------*/
  1236. /* Display info on TCXL and IDC                                         */
  1237.  
  1238. VOID  CTYP  TcxlInfo(NOARG)
  1239. {
  1240.    IntT  i;
  1241.  
  1242.    if(!WpopUp(CNT_CNT, 3, 6, 21, 72, 0, WHITE|_RED, LMAGENTA|_RED))
  1243.       ErrorExit(1);
  1244.  
  1245.    AddShadow();
  1246.  
  1247.    for(i = 0; i < INFO_CNT; i++)
  1248.       WprtCen(TcxlI[i].row, TcxlI[i].Atr, TcxlI[i].Str);
  1249.    KeyTime(200);
  1250.    Wclose();
  1251.    MoveBarDn();
  1252. }
  1253.  
  1254. /*----------------------------------------------------------------------*/
  1255. /* Part of the window demo.                                             */
  1256.  
  1257. VOID  CTYP  ActivDemo(NOARG)
  1258. {
  1259.    REG IntT    i;
  1260.  
  1261.    if(0 == (w[5] = Wopen(9, 44, 22, 78, 1, LCYAN|_CYAN, WHITE|_CYAN)))
  1262.       ErrorExit(1);
  1263.    HlpSet(H_ACTIVATE);
  1264.    Wputs("\n  TCXL's Wactiv() is used to"
  1265.         "\n  activate a window, making"
  1266.         "\n  it available for windowing"
  1267.         "\n  operations.");
  1268.    PressAKey(6);
  1269.  
  1270.    for(i = 0; i < 6; i++)
  1271.    {
  1272.       Wactiv(w[i]);           /* activate windows 0 thru 5 in order,    */
  1273.       DemoWait();             /* back to front                          */
  1274.    }
  1275. }
  1276.  
  1277. /*----------------------------------------------------------------------*/
  1278. /* Part of the window demo.                                             */
  1279.  
  1280. VOID  CTYP  AttrDemo(NOARG)
  1281. {
  1282.    if(0 == (w[1] = Wopen(9, 35, 22, 65, 0, YELLOW|_BLUE, LCYAN|_BLUE)))
  1283.       ErrorExit(1);
  1284.  
  1285.    HlpSet(H_CHGATTR);
  1286.    Wputs("\n  The WchgAtr() function"
  1287.         "\n  allows you to change the"
  1288.         "\n  attribute of the active"
  1289.         "\n  window.");
  1290.    PressAKey(6);
  1291.    ChgWindAttr(LMAGENTA|_BLUE, WHITE|_GREEN);
  1292.    ChgWindAttr(GREEN|_LGREY, LMAGENTA|_RED);
  1293.    ChgWindAttr(YELLOW|_BROWN, LCYAN|_BLUE);
  1294.    ChgWindAttr(YELLOW|_MAGENTA, YELLOW|_MAGENTA);
  1295.    ChgWindAttr(LCYAN|_MAGENTA, WHITE|_MAGENTA);
  1296. }
  1297.  
  1298. /*----------------------------------------------------------------------*/
  1299. /* Part of the window demo.                                             */
  1300.  
  1301. VOID  CTYP  BordDemo(NOARG)
  1302. {
  1303.    REG IntT i;
  1304.  
  1305.    HlpSet(H_CHGBORD);
  1306.    WsetTxt(LGREEN|_MAGENTA);
  1307.    Wputs("\n\n  The Wborder() function is"
  1308.            "\n  used to change the style"
  1309.            "\n  of the window's border.");
  1310.    PressAKey(10);
  1311.    for(i = 5; i >= 0; i--)
  1312.    {
  1313.       Wborder(i);
  1314.       DemoWait();
  1315.    }
  1316. }
  1317.  
  1318. /*----------------------------------------------------------------------*/
  1319. /* Part of the window demo.                                             */
  1320.  
  1321. VOID  CTYP  ChgWindAttr(IntT battr, IntT wattr)
  1322. {
  1323.    WchgAtr(battr, wattr);
  1324.    DemoWait();
  1325. }
  1326.  
  1327. /*----------------------------------------------------------------------*/
  1328. /* The end of the window demo.                                          */
  1329.  
  1330. VOID  CTYP  CloseWinDemo(NOARG)
  1331. {
  1332.    REG IntT    i;
  1333.  
  1334.    for(i = 0; i < 8; i++)
  1335.    {
  1336.       Wclose();
  1337.       DemoWait();
  1338.    }
  1339. }
  1340.  
  1341. /*----------------------------------------------------------------------*/
  1342. /* Validates the Date field in the data entry window.                   */
  1343.  
  1344. IntT  CTYP  CheckDate(ChrP b)
  1345. {
  1346.    IntT  y, m, d;
  1347.  
  1348.    if(!strblank(b))
  1349.    {
  1350.       ParseDate(b, &m, &d, &y);
  1351.  
  1352.       if(m < 1 || m > 12)              /* validate numeric values       */
  1353.       {
  1354.          Wperror("Invalid month");
  1355.          return(1);
  1356.       }
  1357.       if(d < 1 || d > 31)
  1358.       {
  1359.          Wperror("Invalid day");
  1360.          return(3);
  1361.       }
  1362.    }
  1363.    return(0);
  1364. }
  1365.  
  1366. /*----------------------------------------------------------------------*/
  1367. /* Pops open a window and confirms that the user really wants to quit   */
  1368. /* the demo.  If so, it terminates the demo program.                    */
  1369.  
  1370. VOID  CTYP  ConfirmQuit(NOARG)
  1371. {
  1372.    KbndP    kblist;
  1373.  
  1374.    MShide();
  1375.    kblist = KbndChg(NULL);             /* hide any existing hot keys    */
  1376.    if(!Wopen(9, 26, 13, 55, 0, WHITE|_BROWN, WHITE|_BROWN))
  1377.       ErrorExit(1);
  1378.  
  1379.    AddShadow();
  1380.    Wputs("\n Quit demo, are you sure? \033A\156Y\b");
  1381.    KeyClear();
  1382.    VcurHid(1);
  1383.    if(KwGetYn('Y') == 'Y')
  1384.       NormalExit();
  1385.    Wclose();
  1386.    VcurHid(0);
  1387.    KbndChg(kblist);                    /* restore any hidden hot keys   */
  1388.    MSshow();
  1389. }
  1390.  
  1391. /*----------------------------------------------------------------------*/
  1392. /* Part of the window demo.                                             */
  1393.  
  1394. VOID  CTYP  CopyDemo(NOARG)
  1395. {
  1396.    HlpSet(H_WINCOPY);
  1397.    WsetTxt(LCYAN|_CYAN);
  1398.    Wputs("\n\n  The Wcopy() function is used"
  1399.            "\n  to copy the active window.");
  1400.    PressAKey(9);
  1401.    if(!Wcopy(1, 1))
  1402.       ErrorExit(1);
  1403.    DemoWait();
  1404.    if(!Wcopy(3, 40))
  1405.       ErrorExit(1);
  1406.    DemoWait();
  1407. }
  1408.  
  1409. /*----------------------------------------------------------------------*/
  1410. /* Controls delay in demo.                                              */
  1411.  
  1412. VOID  CTYP  DemoWait(NOARG)
  1413. {
  1414.    if(DemoFast)
  1415.       return;
  1416.    else
  1417.       _Delay(5);
  1418. }
  1419.  
  1420. /*----------------------------------------------------------------------*/
  1421. /* Save the screen image on the far heap.                               */
  1422.  
  1423. VcelFP   CTYP  FarVsave(IntT Atr)
  1424. {
  1425.    VcelFP   FarPtr;
  1426.    VcelP    NearPtr;
  1427. #if   (TCXL_cc_ == 2)                  /* Zortech                       */
  1428.    DwdT sz;
  1429. #else
  1430.    WrdT sz;
  1431. #endif
  1432.  
  1433.    if(NULL == (NearPtr = Vsave()))
  1434.       ErrorExit(3);
  1435.    sz = (VidDep * VidWid * SIZ(VcelT)) + 1;
  1436.    if(NULL == (FarPtr = (VcelFP) farmalloc(sz)))
  1437.       ErrorExit(4);
  1438.    _PutFar((BytFP) FarPtr, (BytP) NearPtr, sz);
  1439.    free(NearPtr);
  1440.    Vclear(Atr);
  1441.    return(FarPtr);
  1442. }
  1443.  
  1444. /*----------------------------------------------------------------------*/
  1445. /* Restore saved screen image from the far heap.                        */
  1446.  
  1447. VOID  CTYP  FarVrestore(VcelFP FarPtr)
  1448. {
  1449.    VcelP    NearPtr;
  1450.    WrdT     sz;
  1451.  
  1452.    sz = (VidDep * VidWid * SIZ(VcelT)) + 1;
  1453.    if(NULL == (NearPtr = (VcelP) malloc(sz)))
  1454.       ErrorExit(3);
  1455.    _GetFar((BytP) NearPtr, (BytFP) FarPtr, sz);
  1456.    farfree(FarPtr);
  1457.    Vrestore(NearPtr);
  1458. }
  1459.  
  1460. /*----------------------------------------------------------------------*/
  1461. /* Part of entry demo.  Shows a method of printing entry form data.     */
  1462.  
  1463. VOID  CTYP  PrintOrder(NOARG)
  1464. {
  1465.    IntT  p;
  1466.    IntT  m, d, y;
  1467.  
  1468.    if(!WpopUp(CNT_CNT, 9, 20, 13, 64, 0, WHITE|_CYAN, WHITE|_CYAN))
  1469.       ErrorExit(1);
  1470.  
  1471.    WputCen("Is your printer attached\n");
  1472.    WputCen("to LPT1 and Ready? \033A\076Y\b");
  1473.  
  1474.    strtrim(firstname);
  1475.    strtrim(initial);
  1476.    strtrim(lastname);
  1477.    strtrim(address);
  1478.    strtrim(company);
  1479.    strtrim(city);
  1480.    strtrim(state);
  1481.    strtrim(zipcode);
  1482.    strtrim(comments);
  1483.    strltrim(amtenc);
  1484.  
  1485.    KeyClear();
  1486.    p = KwGetYn('Y');
  1487.    if(p != 'N')
  1488.    {
  1489.       ParseDate(date, &m, &d, &y);
  1490.  
  1491.       Wclear();
  1492.       WputCen("Printing TCXL Order Form . . .\n\n");
  1493.  
  1494.       Wputs("\033C\002Printing Line 1");
  1495.       _Delay(5);
  1496.       lprintf("TCXL Order Form                     "
  1497.             "        %s %d, %d\n\n\n", months[m - 1], d, y);
  1498.       Wputs("\033C\002Printing Line 2");
  1499.       _Delay(5);
  1500.       if(initial[0] == 0)
  1501.          lprintf("%s %s\n\n", firstname, lastname);
  1502.       else
  1503.          lprintf("%s %s. %s\n\n", firstname, initial, lastname);
  1504.  
  1505.       Wputs("\033C\002Printing Line 3");
  1506.       _Delay(5);
  1507.       lprints(company);
  1508.       lprints("\n\n");
  1509.       Wputs("\033C\002Printing Line 4");
  1510.       _Delay(5);
  1511.       lprints(address);
  1512.       lprints("\n\n");
  1513.       Wputs("\033C\002Printing Line 5");
  1514.       _Delay(5);
  1515.       lprintf("%s, %s %s    %3.3s-%3.3s-%4.4s\n\n", city, state,
  1516.          zipcode, &phone[0], &phone[3], &phone[6]);
  1517.       Wputs("\033C\002Printing Line 6");
  1518.       _Delay(5);
  1519.       lprintf("Compiler:  %s     Order Total  $ %s\n\n", compiler,
  1520.          amtenc);
  1521.       Wputs("\033C\002Printing Line 7");
  1522.       _Delay(5);
  1523.       lprints(comments);
  1524.       lprints("\n\n");
  1525.       Wputs("\033C\002Printing Line 8");
  1526.       _Delay(5);
  1527.       lprints("Payment Method:  Check Enclosed \n\n");
  1528.       Wputs("\033C\002Printing Line 9");
  1529.       _Delay(5);
  1530.       lprints("   (circle one)  MasterCard    Visa\n\n");
  1531.       Wputs("\033C\002Printing Line 10");
  1532.       _Delay(5);
  1533.       lprints("                    "
  1534.          "Card Number: ______________________________\n\n");
  1535.       Wputs("\033C\002Printing Line 11");
  1536.       _Delay(5);
  1537.       lprints("                    "
  1538.          "Expiration Date ___________________________\n\n\n");
  1539.       Wputs("\033C\002Printing Line 12");
  1540.       _Delay(5);
  1541.       lprints("                    "
  1542.          "Signature _________________________________\n");
  1543.       lprintc('\x0c');
  1544.    }
  1545.    Wclose();
  1546. }
  1547.  
  1548. /*----------------------------------------------------------------------*/
  1549. /* Displays a quick 'n' dirty directory of current path -- uses new     */
  1550. /* TCXL stuff that is compiler independent!                             */
  1551.  
  1552. VOID  CTYP  Directory(NOARG)
  1553. {
  1554.    LCL IntT    bf = 0;
  1555.    ChrT        fs[41], f1[13], f2[13];
  1556.    IntT        i, f, l, n;
  1557.    FfbT        fb;
  1558.  
  1559.    if(bf)                              /* AVOID RECURSION!              */
  1560.       return;
  1561.  
  1562.    else
  1563.       bf = 1;
  1564.  
  1565.    strcpy(fs, "*.*");
  1566.    VcurHid(1);
  1567.    if(!Wopen(4, 14, 20, 59, 0, YELLOW|_BLUE, YELLOW|_BLUE))
  1568.       ErrorExit(1);
  1569.  
  1570.    Wtitle("[ Directory ]", TTL_CNT, YELLOW|_BLUE);
  1571.    if(!Wopen(6, 6, 8, 49, 0, LCYAN|_RED, LCYAN|_RED))
  1572.       ErrorExit(1);
  1573.  
  1574.    Wtitle("[ Filespec ]", TTL_CNT, LCYAN|_RED);
  1575.    EntDef(BLUE|_LGREY, BLUE|_LGREY);
  1576.    EntFld(0, 1, fs, "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", FLD_UPR,
  1577.       13, 2, NULL, H_EDITKEYS);
  1578.    i = EntShow();
  1579.    Wclose();
  1580.    if(!i)
  1581.    {
  1582.       Wclear();
  1583.       WsetTxt(LCYAN|_BLUE);
  1584.       l = n = 0;
  1585.       f = _FndFst(fs, &fb, 0);
  1586.       for(;;)
  1587.       {
  1588.          if(f)
  1589.             break;
  1590.          n++;
  1591.          strcpy(f1, FfbNam(fb));
  1592.          if(!f)
  1593.             f = _FndNxt(&fb);
  1594.          strcpy(f2, FfbNam(fb));
  1595.          if(f)
  1596.             f2[0] = EOS;
  1597.          else
  1598.          {
  1599.             n++;
  1600.             f = _FndNxt(&fb);
  1601.          }
  1602.          if(f)
  1603.             FfbNam(fb)[0] = EOS;
  1604.          else
  1605.             n++;
  1606.          Wputf(" %-15s%-15s%s\n", f1, f2, FfbNam(fb));
  1607.          l++;
  1608.          if(l >= 14)
  1609.          {
  1610.             WsetTxt(LGREEN|_BLUE);
  1611.             Wputf(" Press a key to continue....");
  1612.             WsetTxt(LCYAN|_BLUE);
  1613.             i = (ChrT) KeyTime(36);
  1614.             Wputf("\r");
  1615.             if(i == ESC)
  1616.                break;
  1617.             l = 0;
  1618.          }
  1619.          if(!f)
  1620.             f = _FndNxt(&fb);
  1621.       }
  1622.       WsetTxt(LGREEN|_BLUE);
  1623.       Wputf(" Files found:  %d  Press a key....", n);
  1624.       KeyTime(36);
  1625.    }
  1626.    VcurHid(0);
  1627.    Wclose();
  1628.    bf = 0;                             /* not busy                      */
  1629. }
  1630.  
  1631. /*----------------------------------------------------------------------*/
  1632. /* Displays the literal equivalent of the MMDDYY date that the user     */
  1633. /* entered into the Date field.  It is called immediately after the     */
  1634. /* user leaves the Date field.                                          */
  1635.  
  1636. VOID  CTYP  DisplayDate(NOARG)
  1637. {
  1638.    FdfP  f;
  1639.    IntT  m, d, y;
  1640.  
  1641.    if(NULL == (f = FldLoc(1)))            /* find address of Date field */
  1642.       ErrorExit(1);
  1643.  
  1644.    VcurHid(0);                            /* set cursor and clear to    */
  1645.    Wgotoxy(1, 37);                        /* end of window's line       */
  1646.    WclrEol();
  1647.    if(!strblank(FdfBfr(f)))               /* parse string date into     */
  1648.    {                                      /*numeric values              */
  1649.       ParseDate(FdfBfr(f), &m, &d, &y);
  1650.       Wputf("%s %d, %d", months[m - 1], d, y);
  1651.    }
  1652.    VcurHid(1);
  1653. }
  1654.  
  1655. /*----------------------------------------------------------------------*/
  1656. /* Called by the pull-down demo for a prompt.                           */
  1657.  
  1658. VOID  CTYP  DispSureMsg(NOARG)
  1659. {
  1660.    Wprts(0, 2, WHITE|_BLUE, "Are you sure?");
  1661. }
  1662.  
  1663. /*----------------------------------------------------------------------*/
  1664. /* Part of the window demo.                                             */
  1665.  
  1666. VOID  CTYP  DisplayTitle(IntT tpos)
  1667. {
  1668.    Wtitle("[ My Title ]", tpos, LCYAN|_GREEN);
  1669.    DemoWait();
  1670. }
  1671.  
  1672. /*----------------------------------------------------------------------*/
  1673. /* Dummy function for several menu items in the pull-down demo          */
  1674.  
  1675. VOID  CTYP  DoNothing(NOARG)
  1676. {
  1677. }
  1678.  
  1679. /*----------------------------------------------------------------------*/
  1680. /* Abnormal termination.  If it is passed an  error code of 1, then it  */
  1681. /* is a windowing system error.  Otherwise the error message is looked  */
  1682. /* up in the error message table.                                       */
  1683.  
  1684. VOID  CTYP   ErrorExit(IntT e)
  1685. {
  1686.    if(e)
  1687.    {
  1688.       if(e == 1)
  1689.          Werror();
  1690.       else
  1691.          printf("\n%s\n", error_text[e]);
  1692.       exit(e);
  1693.    }
  1694. }
  1695.  
  1696. /*----------------------------------------------------------------------*/
  1697. /* Used by the pull-down demo to execute a DOS command.                 */
  1698.  
  1699. VOID  CTYP  Execute(NOARG)
  1700. {
  1701.    LCL      IntT bf = 0;
  1702.    ChrT     cd[61];
  1703.  
  1704.    if(bf)                              /* AVOID RECURSION!              */
  1705.       return;
  1706.    else
  1707.       bf = 1;
  1708.    if(!Wopen(8, 7, 10, 70, 0, LGREY|_RED, LGREY|_RED))
  1709.       ErrorExit(1);
  1710.    Wtitle("[ Execute DOS Command ]", TTL_CNT, LGREY|_RED);
  1711.    EntDef(BLUE|_LGREY, BLUE|_LGREY);
  1712.    EntFld(0, 1, cd,
  1713.       "************************************************************",
  1714.       FLD_NUL, 14, 0, NULL, H_EDITKEYS);
  1715.    if(!EntShow())
  1716.       OsShell1(cd);
  1717.    VcurHid(0);
  1718.    Wclose();
  1719.    bf = 0;
  1720. }
  1721.  
  1722. /*----------------------------------------------------------------------*/
  1723. /* Alternate get key function for the data entry demo.  In this example,*/
  1724. /* I do a normal keyboard get, but if the key is [F10], I want to exit  */
  1725. /* the form. The purpose of this is to show how to extend EntShow().    */
  1726. /* If F9 is pressed, we fill in today's date to the keyboard buffer     */
  1727.  
  1728. WrdT  CTYP  GetKey(IntP d)
  1729. {
  1730.    KeyT  x;
  1731.    ChrP  b;
  1732.  
  1733.    x = KeyGetc();
  1734.    if(x == Key_F9)
  1735.    {
  1736.       b = SysDate(2);
  1737.       KqueStr(&b[1]);
  1738.       x = b[0];
  1739.    }
  1740.    else
  1741.       *d = (x == Key_F10);
  1742.    return(x);
  1743. }
  1744.  
  1745. /*----------------------------------------------------------------------*/
  1746. /* Part of the window demo.                                             */
  1747.  
  1748. VOID  CTYP  HideDemo(NOARG)
  1749. {
  1750.    REG IntT i;
  1751.  
  1752.    HlpSet(H_WINHIDE);
  1753.    WsetTxt(YELLOW|_CYAN);
  1754.    Wputs("\n\n   The Whide() and Wunhide()"
  1755.            "\n   functions are used to hide"
  1756.            "\n   and unhide windows.");
  1757.    PressAKey(13);
  1758.    for(i = 0; i < 5; i++)
  1759.    {
  1760.       if(Whide())                      /* hide all windows, front to    */
  1761.          ErrorExit(1);                 /* back                          */
  1762.       DemoWait();
  1763.    }
  1764.    for(i = 0; i < 5; i++)
  1765.    {
  1766.       if(Wunhide(0))                   /* unhide most recently hidden   */
  1767.          ErrorExit(1);                 /* first                         */
  1768.       DemoWait();
  1769.    }
  1770. }
  1771.  
  1772. /*----------------------------------------------------------------------*/
  1773. /* Part of the window demo.                                             */
  1774.  
  1775. VOID  CTYP  HorzLine(IntT r, IntT c, IntT n, IntT a)
  1776. {
  1777.    WdrwHor(r, c, n, 3, a);
  1778.    DemoWait();
  1779. }
  1780.  
  1781. /*----------------------------------------------------------------------*/
  1782. /* Part of the strings demo.                                            */
  1783.  
  1784. VOID  CTYP  Dstrmatch(NOARG)
  1785. {
  1786.    ChrP str1 = "xhelpx";
  1787.    IntT i = 0;
  1788.  
  1789.    while(Dstrings[i] != NULL)
  1790.    {
  1791.       Wputf(" <%s> vs. <%s> = <%d>\n",
  1792.            str1, Dstrings[i], strmatch(str1, Dstrings[i]));
  1793.       i++;
  1794.    }
  1795.  
  1796.    Wputf(" <%s> best matches <%s>\n", str1, strbmatch(str1, Dstrings));
  1797. }
  1798.  
  1799. /*----------------------------------------------------------------------*/
  1800. /* Part of the strings demo.                                            */
  1801.  
  1802. VOID  CTYP  Dstrtrim(NOARG)
  1803. {
  1804.    ChrP  str1 = "     Hello, world     ";
  1805.    ChrT  str2[25];
  1806.  
  1807.    strcpy(str2, str1);
  1808.    strltrim(str2);
  1809.    Wputf(BefAft, str1, str2);
  1810.  
  1811.    strcpy(str2, str1);
  1812.    strrtrim(str2);                     /* identical to strtrim()        */
  1813.    Wputf(BefAft, str1, str2);
  1814.  
  1815.    strcpy(str2, str1);
  1816.    strbtrim(str2);
  1817.    Wputf(BefAft, str1, str2);
  1818.  
  1819. }
  1820. /*----------------------------------------------------------------------*/
  1821. /* Part of the strings demo.                                            */
  1822.  
  1823. VOID  CTYP  Dstrchg(NOARG)
  1824. {
  1825.    ChrP  str1 = "HelLo, worLd";
  1826.    ChrP  str2 = "Hello, world";
  1827.    ChrP  str3 = "xxxhElLoyyyHElLOzzz";
  1828.    ChrP  str4 = "xxxhElloyyyhellozzz";
  1829.    ChrT  str5[30];
  1830.  
  1831.    strcpy(str5, str1);
  1832.    strchg(str5, 'l', 'z');
  1833.    Wputf(BefAft, str1, str5);
  1834.  
  1835.    strcpy(str5, str2);
  1836.    strichg(str5, 'l', 'z');
  1837.    Wputf(BefAft, str2, str5);
  1838.  
  1839.    strcpy(str5, str3);
  1840.    strischg(str5, "HeLlO", "goodbye");
  1841.    Wputf(BefAft, str3, str5);
  1842.  
  1843.    strcpy(str5, str4);
  1844.    strschg(str5, "hello", "goodbye");
  1845.    Wputf(BefAft, str4, str5);
  1846. }
  1847.  
  1848. /*----------------------------------------------------------------------*/
  1849. /* Part of the strings demo.                                            */
  1850.  
  1851. VOID  CTYP  Dstrchksum(NOARG)
  1852. {
  1853.    ChrP  str1 = "Hello, world";
  1854.  
  1855.    Wputf("Checksum is %lu, I-Checksum is %lu\n",
  1856.         strchksum(str1), strichksum(str1));
  1857. }
  1858.  
  1859. /*----------------------------------------------------------------------*/
  1860. /* Part of the strings demo.                                            */
  1861.  
  1862. VOID  CTYP  Dstrdel(NOARG)
  1863. {
  1864.    ChrP  str1 = "XyZHello, xYzworldXyZxYz";
  1865.    ChrT  str2[35];
  1866.  
  1867.    strcpy(str2, str1);
  1868.    strdel("xYz", str2);
  1869.    Wputf(BefAft, str1, str2);
  1870.  
  1871.    strcpy(str2, str1);
  1872.    strdela("xYz", str2);
  1873.    Wputf(BefAft, str1, str2);
  1874.  
  1875.    strcpy(str2, str1);
  1876.    stridel("xYz", str2);
  1877.    Wputf(BefAft, str1, str2);
  1878.  
  1879.    strcpy(str2, str1);
  1880.    stridela("xYz", str2);
  1881.    Wputf(BefAft, str1, str2);
  1882.  
  1883.    strcpy(str1, str2);
  1884.    strins("xYz", str2, 4);
  1885.    Wputf(BefAft, str1, str2);
  1886. }
  1887.  
  1888. /*----------------------------------------------------------------------*/
  1889. /* Part of the strings demo.                                            */
  1890.  
  1891. VOID  CTYP  Dstrinc(NOARG)
  1892. {
  1893.    ChrP  str1 = "Hello1HELLO2HeLlO3hElLo";
  1894.    ChrP  str2 = "hello";
  1895.  
  1896.    Wputf("str2 is %sincluded in str1\n",
  1897.       ((strinc(str2, str1) == NULL) ? "not " : ""));
  1898.  
  1899.    Wputf("str2 is %sincluded in str1\n",
  1900.         ((striinc(str2, str1) == NULL) ? "not " : ""));
  1901.  
  1902.    Wputf("There are %d occurrences of '%c' in str1\n",
  1903.         strocc(str1, 'l'), 'l');
  1904.  
  1905.    Wputf("There are %d occurrences of '%c' in str1\n",
  1906.         striocc(str1, 'l'), 'l');
  1907.  
  1908.    Wputf("str2 occurs in str1 %d times\n",
  1909.         strsocc(str2, str1));
  1910.    Wputf("str2 occurs in str1 %d times\n",
  1911.         strisocc(str2, str1));
  1912. }
  1913.  
  1914. /*----------------------------------------------------------------------*/
  1915. /* Part of the strings demo.                                            */
  1916.  
  1917. VOID  CTYP  Dstrsrep(NOARG)
  1918. {
  1919.    ChrP  str1 = "This is a big string";
  1920.    ChrT  str2[25];
  1921.  
  1922.    strcpy(str2, str1);
  1923.    strsrep(str2, "str", "th");
  1924.    Wputf(BefAft, str1, str2);
  1925.  
  1926.    strcpy(str2, str1);
  1927.    strisrep(str2, "str", "th");
  1928.    Wputf(BefAft, str1, str2);
  1929.  
  1930. }
  1931.  
  1932. /*----------------------------------------------------------------------*/
  1933. /* Part of the strings demo.                                            */
  1934.  
  1935. VOID  CTYP  Dstrmid(NOARG)
  1936. {
  1937.    ChrP  p;
  1938.    ChrP  str = "Hello, world";
  1939.  
  1940.    Wputf("    %s\n", p = strmid(str, 5, 5));
  1941.    free(p);
  1942.  
  1943.    Wputf("    %s\n", p = strleft(str, 5));
  1944.    free(p);
  1945.  
  1946.    Wputf("    %s\n", p = strright(str, 5));
  1947.    free(p);
  1948. }
  1949.  
  1950. /*----------------------------------------------------------------------*/
  1951. /* Part of the strings demo.                                            */
  1952.  
  1953. VOID  CTYP  Dstrljust(NOARG)
  1954. {
  1955.    ChrP  str1 = "     Hello, world     ";
  1956.    ChrP  str2 = "Hello, world";
  1957.    ChrT  str3[25];
  1958.  
  1959.    strcpy(str3, str1);
  1960.    strljust(str3);
  1961.    Wputf(BefAft, str1, str3);
  1962.  
  1963.    strcpy(str3, str1);
  1964.    strrjust(str3);
  1965.    Wputf(BefAft, str1, str3);
  1966.  
  1967.    strcpy(str3, str2);
  1968.    strrol(str3, 3);
  1969.    Wputf(BefAft, str2, str3);
  1970.  
  1971.    strcpy(str3, str2);
  1972.    strror(str3, 3);
  1973.    Wputf(BefAft, str2, str3);
  1974.  
  1975.    strcpy(str3, str2);
  1976.    strshl(str3, 3);
  1977.    Wputf(BefAft, str2, str3);
  1978.  
  1979.    strcpy(str3, str2);
  1980.    strshr(str3, 3);
  1981.    Wputf(BefAft, str2, str3);
  1982. }
  1983.  
  1984. /*----------------------------------------------------------------------*/
  1985. /* Part of the strings demo.                                            */
  1986.  
  1987. VOID  CTYP  Dstrblank(NOARG)
  1988. {
  1989.    ChrP  str1 = "  Hello  ";
  1990.    ChrP  str2 = " \n  \t \r ";
  1991.    ChrP  str3 = "Hello, world";
  1992.    ChrP  str4 = "hElLo, wOrLd";
  1993.    ChrT  str5[25];
  1994.  
  1995.    Wputf(" str1 is %sblank\n", strblank(str1) ? "" : "not ");
  1996.    Wputf(" str2 is %sblank\n", strblank(str2) ? "" : "not ");
  1997.  
  1998.    Wputf(" Before:    <%s>\n", str3);
  1999.    strcode(str3, "34&*#Mdq");
  2000.    Wputf(" Encrypted: <%s>\n", str3);
  2001.    strcode(str3, "34&*#Mdq");
  2002.    Wputf(" Decrypted: <%s>\n", str3);
  2003.  
  2004.    strcpy(str5, str3);
  2005.    Wputf(" Before:  <%s>\n", str5);
  2006.    strsetsz(str5, 20);
  2007.    Wputf(" Len=20:  <%s>\n", str5);
  2008.    strsetsz(str5, 5);
  2009.    Wputf(" Len=5:   <%s>\n", str5);
  2010.  
  2011.    strcpy(str5, str4);
  2012.    struplow(str5);
  2013.    Wputf(BefAft, str4, str5);
  2014. }
  2015.  
  2016. /*----------------------------------------------------------------------*/
  2017. /* Part of menu demo -- build arrays of valid Ultravision modes         */
  2018.  
  2019. IntT  CTYP  ValidModes(NOARG)
  2020. {
  2021.    int   i, n, q, r;
  2022.  
  2023.    q = _VuvGet();
  2024.    n = 0;
  2025.  
  2026.    for(i = 0; UvMode[i] != 0; i++)
  2027.    {
  2028.       if(_VuvVal(UvMode[i]) == 0)
  2029.       {
  2030.          UvVal[n] = UvArr[i];
  2031.          UvMd[n++] = UvMode[i];
  2032.          if(q == UvMode[i])
  2033.             r = n - 1;
  2034.       }
  2035.    }
  2036.    UvVal[n] = NULL;
  2037.    return(r);
  2038. }
  2039.  
  2040. /*----------------------------------------------------------------------*/
  2041. /* Part of menu demo -- change screen size                              */
  2042.  
  2043. VOID  CTYP  ChangeSize(NOARG)
  2044. {
  2045.    int   s, t, st, w;
  2046.  
  2047.    st = VcurHid(-1);
  2048.    w = VidWid;
  2049.    if(VuvAct)
  2050.    {
  2051.       t = ValidModes();
  2052.       s = SelStr(4, 45, 12, 74, 0, LGREY|_BLUE, YELLOW|_BLUE,
  2053.           YELLOW|_MAGENTA, UvVal, t, NULL);
  2054.       if(s >= 0)
  2055.          _VuvSet(UvMd[s]);
  2056.    }
  2057.    else
  2058.    {
  2059.       if(VidWid != 80)
  2060.          Wperror("Invalid Screen Width to Demonstrate");
  2061.       else
  2062.       {
  2063.          if(VisaEga() != -1)
  2064.          {
  2065.             s = SelStr(4, 57, 8, 71, 0, LGREY|_BLUE, YELLOW|_BLUE,
  2066.                    YELLOW|_MAGENTA, LinArr,
  2067.                    ((VidDep == 43) ? 1 : ((VidDep == 50) ? 2 : 0)), NULL);
  2068.             switch(s)
  2069.             {
  2070.                case 0:
  2071.                   VsetLin(25);
  2072.                   break;
  2073.                case 1:
  2074.                   VsetLin(43);
  2075.                   break;
  2076.                case 2:
  2077.                   VsetLin(50);
  2078.                   break;
  2079.             }
  2080.          }
  2081.       }
  2082.    }
  2083.    if(w != VidWid)
  2084.       cvtic(&Rmargin[16], VidWid - 8, 3);
  2085.    VcurHid(st);
  2086. }
  2087.  
  2088. /*----------------------------------------------------------------------*/
  2089. /* Part of menu demo -- draw a fake editor screen                       */
  2090.  
  2091. VOID  CTYP  DrawEditor(IntT Lmar, IntT Rmar)
  2092. {
  2093.    IntT i = 0, j;
  2094.  
  2095.    if(!Wopen(0, 0, VidDep - 1, VidWid - 1, 0, CYAN, CYAN))
  2096.       ErrorExit(1);
  2097.  
  2098.    WdrwHor(1, 0, VidWid - 2, 0, CYAN);
  2099.    if(!Wopen(3, Lmar + 1, VidDep - 2, Rmar + 1, BOX_SPA, CYAN, CYAN))
  2100.       ErrorExit(1);
  2101.  
  2102.    Wgotoxy(0, 0);
  2103.    WsetTxt(YELLOW);
  2104.  
  2105.    while(Edemo[i]  != NULL)
  2106.       Wputsw(Edemo[i++]);
  2107.  
  2108.    if(MouInit)
  2109.       Wputsw("  Since you have a mouse, you can use it to move around "
  2110.             "and select options!");
  2111.  
  2112.    j = WdfPosR(WctlAct);
  2113.  
  2114.    for(i = 0; i < 6; i++)
  2115.       WprtCen(TcxlI[i].row + j, TcxlI[i].Atr, TcxlI[i].Str);
  2116.  
  2117. }
  2118.  
  2119. /*----------------------------------------------------------------------*/
  2120. /* Used to move the selection bar of the Main Menu down to the next menu*/
  2121. /* item.  It does this by fetching the address of the current menu, then*/
  2122. /* setting the current tagid to the tagid of the next menu item.  If I  */
  2123. /* had not numbered the menu items' tagids sequentially, this would not */
  2124. /* work.                                                                */
  2125.  
  2126. VOID  CTYP  MoveBarDn(NOARG)
  2127. {
  2128.    ItmNxt(IdfTag(ItmCur()) + 1);
  2129. }
  2130.  
  2131. /*----------------------------------------------------------------------*/
  2132. /* Part of the window demo.                                             */
  2133.  
  2134. VOID  CTYP  MoveDemo(NOARG)
  2135. {
  2136.    IntT i;
  2137.  
  2138.    if(0 == (w[4] = Wopen(4, 2, 20, 35, 2, YELLOW|_CYAN, YELLOW|_CYAN)))
  2139.       ErrorExit(1);
  2140.  
  2141.    HlpSet(H_WINMOVE);
  2142.    Wputs("\n   To move the active window,"
  2143.          "\n   the Wmove() function is"
  2144.          "\n   used.");
  2145.    PressAKey(5);
  2146.  
  2147.    for(i = 0; i < 6; i++)
  2148.       MoveWindow(Siz3[i], Siz4[i]);
  2149.  
  2150.    Wputs("\n\n   Or if you prefer flashier,"
  2151.            "\n   window movement, try"
  2152.            "\n   Wslide() instead.");
  2153.    PressAKey(9);
  2154.  
  2155.    for(i = 0; i < 6; i++)
  2156.       DragWindow(Siz3[i], Siz4[i]);
  2157. }
  2158.  
  2159. /*----------------------------------------------------------------------*/
  2160. /* part of the window demo                                              */
  2161.  
  2162. VOID  CTYP  AddShadow(NOARG)
  2163. {
  2164.    Wshadow(LGREY|_BLACK);
  2165. }
  2166.  
  2167. /*----------------------------------------------------------------------*/
  2168. /* part of the window demo                                              */
  2169.  
  2170. VOID  CTYP  MoveWindow(IntT r, IntT c)
  2171. {
  2172.    if(Wmove(r, c))
  2173.       ErrorExit(1);
  2174.  
  2175.    DemoWait();
  2176. }
  2177.  
  2178. /*----------------------------------------------------------------------*/
  2179. /* part of the window demo                                              */
  2180.  
  2181. VOID  CTYP  DragWindow(IntT r, IntT c)
  2182. {
  2183.    if(Wslide(r, c))
  2184.       ErrorExit(1);
  2185.    DemoWait();
  2186. }
  2187.  
  2188. /*----------------------------------------------------------------------*/
  2189. /* Normal termination.  The original screen and cursor  coordinates are */
  2190. /* restored before exiting to DOS with ERRORLEVEL 0.                    */
  2191.  
  2192. VOID  CTYP  NormalExit(NOARG)
  2193. {
  2194.    FarVrestore(savescrn);
  2195.    MSpop();
  2196.    VcurPut(rc);
  2197.    VcurHid(1);
  2198.    exit(0);
  2199. }
  2200.  
  2201. /*----------------------------------------------------------------------*/
  2202. /* Used by the pull-down demo.  It is the [O]S Shell function under the */
  2203. /* [F]ile menu                                                          */
  2204.  
  2205. VOID  CTYP  OsShell(NOARG)
  2206. {
  2207.    OsShell1("");
  2208. }
  2209.  
  2210. /*----------------------------------------------------------------------*/
  2211. /* Does the work for OsShell()                                          */
  2212.  
  2213. VOID  CTYP  OsShell1(ChrP Cmd)
  2214. {
  2215.    VcelFP   s;
  2216.    ChrT     c;
  2217.  
  2218.    c = *Cmd;
  2219.    VcurHid(1);
  2220.    MShide();
  2221.    s = FarVsave(LGREY|_BLACK);
  2222.    if(c == EOS)
  2223.       printf("Type EXIT to return....\n");
  2224.    system(Cmd);
  2225.    if(c != EOS)
  2226.    {  printf("Press a key to return....\n");
  2227.       KeyWait();
  2228.    }
  2229.    FarVrestore(s);
  2230.    VcurHid(0);
  2231.    MSshow();
  2232. }
  2233.  
  2234. /*----------------------------------------------------------------------*/
  2235. /* Parses a MMDDYY date string into separate numeric values.            */
  2236.  
  2237. VOID  CTYP  ParseDate(ChrP b, IntP m, IntP d, IntP y)
  2238. {
  2239.    ChrT  t[7];
  2240.  
  2241.    strcpy(t, b);
  2242.    *y = 1900 + atoi(t + 4);
  2243.    *(t + 4) = EOS;
  2244.    *d = atoi(t + 2);
  2245.    *(t + 2) = EOS;
  2246.    *m = atoi(t);
  2247. }
  2248.  
  2249. /*----------------------------------------------------------------------*/
  2250. /* Part of entry demo -- string picking using a menu                    */
  2251.  
  2252. VOID  CTYP  PickCompiler(NOARG)
  2253. {
  2254.    REG IntT    s, i;
  2255.  
  2256.    HlpCur();
  2257.  
  2258.    MnuBeg(9, 22, 14, 38, 0, BLUE|_MAGENTA, BLUE|_MAGENTA, PreMenu1);
  2259.    for(i = 0; i < 4; i++)
  2260.       MnuItm(i, 0, compilers[i], *compilers[i], i + 1, 0, NULL, 0, 0);
  2261.    MnuEnd(1, MNU_VER, 15, 1, BLUE|_MAGENTA, LCYAN|_MAGENTA, 0,
  2262.       BLUE|_LGREY);
  2263.  
  2264.    if((s = MnuShow()) == -1)
  2265.       ErrorExit(1);
  2266.    KquePut(Key_Home);
  2267.    if(s)
  2268.    {
  2269.       KqueStr(compilers[--s]);
  2270.       KquePut(Key_C_U);
  2271.    }
  2272.                /* put either [Tab] or [Shift-Tab] into TCXL's keyboard  */
  2273.                /* buffer depending on direction entered field from      */
  2274.    KquePut(FdfUp(FldCur()) ? Key_S_Tab : Key_Tab);
  2275.    HlpPop();
  2276. }
  2277.  
  2278. /*----------------------------------------------------------------------*/
  2279. /* Part of menu demo -- sample popup menu                               */
  2280.  
  2281. VOID  CTYP  PopupDemo(NOARG)
  2282. {
  2283.    HlpPush(H_PULLDOWN);
  2284.    MnuBeg(7, 15, 10, 65, 0, LRED, LCYAN|_BLUE, NULL);
  2285.    MnuItm(0, 0, "Add", 'A', 55, 0, NULL, 0, H_NONE);
  2286.    ItmTxt(1, 0, LGREEN|_BLUE, "Create a new record");
  2287.    MnuItm(0, 8, "Delete", 'D', 56, 0, NULL, 0, H_NONE);
  2288.    ItmTxt(1, 0, LGREEN|_BLUE, "Delete an existing record");
  2289.    MnuItm(0, 19, "Print", 'P', 57, 0, NULL, 0, H_NONE);
  2290.    ItmTxt(1, 0, LGREEN|_BLUE, "Print hardcopy of existing record");
  2291.    MnuItm(0, 28, "Show", 'S', 58, 0, NULL, 0, H_NONE);
  2292.    ItmTxt(1, 0, LGREEN|_BLUE, "Display an existing record on screen");
  2293.    MnuItm(0, 36, "Update", 'U', 59, 0, NULL, 0, H_NONE);
  2294.    ItmTxt(1, 0, LGREEN|_BLUE, "Modify an existing record");
  2295.    MnuItm(0, 45, "Quit", 'Q', 60, 0, NULL, 0, H_NONE);
  2296.    ItmTxt(1, 0, LGREEN|_BLUE, "Quit and return to pull-down menu");
  2297.    MnuEnd(55, MNU_HOR, 0, 0, LMAGENTA|_BLUE, WHITE|_BLUE, 0,
  2298.       YELLOW|_LGREY);
  2299.    MnuShow();
  2300.    HlpDrop();
  2301. }
  2302.  
  2303. /*----------------------------------------------------------------------*/
  2304. /* Called after the user presses help and the help window appears. First*/
  2305. /* adds a shadow to the help window, then defines Alt-X to be the key to*/
  2306. /* quit the demo.                                                       */
  2307.  
  2308. VOID  CTYP  PreHelp(NOARG)
  2309. {
  2310.    AddShadow();
  2311.    KbndSet(Key_A_X, ConfirmQuit, 0);
  2312. }
  2313.  
  2314. /*----------------------------------------------------------------------*/
  2315. /* Called during the setup of the main menu by MnuShow() right after    */
  2316. /* the main menu's window is opened.                                    */
  2317.  
  2318. VOID  CTYP  PreMenu1(NOARG)
  2319. {
  2320.    VcurHid(0);
  2321.    AddShadow();
  2322. }
  2323.  
  2324. /*----------------------------------------------------------------------*/
  2325. /* Called during the List Picking demo by SelStr() right after the   */
  2326. /* string picker's window is opened.                                    */
  2327.  
  2328. VOID  CTYP  PrePick1(NOARG)
  2329. {
  2330.    Wmessage("* *", BRD_BOT, 4, LGREEN|_RED);
  2331.    AddShadow();
  2332. }
  2333.  
  2334. /*----------------------------------------------------------------------*/
  2335. /* Pauses for a keypress.                                               */
  2336.  
  2337. VOID  CTYP  PressAKey1(IntT r, IntT w)
  2338. {
  2339.    REG IntT a;
  2340.  
  2341.    if(DemoFast)
  2342.       return;
  2343.  
  2344.    a = (_BLINK|YELLOW)|((WdfDat(WctlAct) >> 4) << 4);
  2345.    WprtCen(r, a, "Press a key");
  2346.    VcurHid(0);
  2347.    if(w == -1)
  2348.       KeyWait();
  2349.    else
  2350.    {
  2351.       if((ChrT) KeyTime(w) == ESC)
  2352.          ConfirmQuit();
  2353.    }
  2354.    WprtCen(r, a, "           ");
  2355. }
  2356.  
  2357. /*----------------------------------------------------------------------*/
  2358. /* Displays a pause message, then pauses for a keypress.                */
  2359.  
  2360. VOID  CTYP  PressAKey(IntT r)
  2361. {
  2362.    PressAKey1(r, 36);
  2363. }
  2364.  
  2365. /*----------------------------------------------------------------------*/
  2366. /* Called by the pull-down menu demo anytime the selection bar moves on */
  2367. /* or off the [Q]uit menu items.                                        */
  2368.  
  2369. VOID  CTYP  QuitWindow(NOARG)
  2370. {
  2371.    LCL WndT    h = 0;
  2372.  
  2373.    if(h)
  2374.    {
  2375.       Wactiv(h);
  2376.       Wclose();
  2377.       h = 0;
  2378.    }
  2379.    else
  2380.    {
  2381.       h = Wopen(14, 41, 17, 70, 0, YELLOW|_RED, WHITE|_RED);
  2382.       Wputs(" Quit takes you back to the\n demo program's main menu.");
  2383.    }
  2384. }
  2385.  
  2386. /*----------------------------------------------------------------------*/
  2387. /* Validates the [R]ight margin setting from RMargin()                  */
  2388.  
  2389. IntT  CTYP  ValidMarg(ChrP Input)
  2390. {
  2391.    if((atoi(Input) > (VidWid - 3)) || (atoi(Input) < 0))
  2392.    {
  2393.       Wperror("Invalid Margin!");
  2394.       return(1);
  2395.    }
  2396.    if(IdfTag(ItmCur()) == 37)
  2397.    {
  2398.       if(atoi(Input) >= atoi(&Rmargin[16]))
  2399.       {
  2400.          Wperror("Left Margin Too Large!");
  2401.          return(1);
  2402.       }
  2403.    }
  2404.    else
  2405.    {
  2406.       if(atoi(&Lmargin[16]) >= atoi(Input))
  2407.       {
  2408.          Wperror("Right Margin Too Small!");
  2409.          return(1);
  2410.       }
  2411.    }
  2412.    return(0);
  2413. }
  2414.  
  2415. /*----------------------------------------------------------------------*/
  2416. /* Gets a new [R]ight margin setting under the [D]efault pull-down menu.*/
  2417.  
  2418. VOID  CTYP  RMargin(NOARG)
  2419. {
  2420.    EntDef(WHITE|_CYAN, WHITE|_CYAN);
  2421.    EntFld(IdfSpoR(ItmCur()), 17, (IdfStr(ItmCur())) + 16,
  2422.          "%%#", FLD_NUM, 15, 1, ValidMarg, 0);
  2423.    EntShow();
  2424.    VcurHid(0);
  2425.    ItmDsp((IdfTag(ItmCur())));
  2426. }
  2427.  
  2428. /*----------------------------------------------------------------------*/
  2429. /* Part of the window demo.                                             */
  2430.  
  2431. VOID  CTYP  ResizeDemo(NOARG)
  2432. {
  2433.    IntT i;
  2434.  
  2435.    HlpSet(H_RESIZE);
  2436.    WsetTxt(BLUE|_GREEN);
  2437.    Wputs("\n\n\n  The Wsize() function"
  2438.              "\n  allows you to resize"
  2439.              "\n  the active window.");
  2440.    PressAKey(10);
  2441.  
  2442.    for(i = 0; i < 6; i++)
  2443.       SizeWindow(Siz1[i], Siz2[i]);
  2444. }
  2445.  
  2446. /*----------------------------------------------------------------------*/
  2447. /* Used by input demo                                                   */
  2448.  
  2449. VOID  CTYP  RestoreCursor(NOARG)
  2450. {
  2451.    WsetTxt(WHITE|_MAGENTA);
  2452.    VcurHid(1);
  2453. }
  2454.  
  2455. /*----------------------------------------------------------------------*/
  2456. /* Part of the window demo.                                             */
  2457.  
  2458. VOID  CTYP  ScrollDemo(NOARG)
  2459. {
  2460.    REG IntT    i, j;
  2461.  
  2462.    if(0 == (w[0] = Wopen(1, 1, 11, 41, 2, LMAGENTA|_RED, LCYAN|_RED)))
  2463.       ErrorExit(1);
  2464.    HlpSet(H_SCROLL);
  2465.    Wputf("\n  TCXL's window TTY output functions"
  2466.          "\n  such as Wputs() and Wprintf() allow"
  2467.          "\n  scrolling and ANSI-like Escape code"
  2468.          "\n  sequences from inside of windows.");
  2469.    PressAKey(6);
  2470.    Wgotoxy(8, 0);
  2471.    for(i = 0; i < 10; i++)
  2472.    {
  2473.       for(j = DGREY; j <= WHITE; j++)
  2474.       {
  2475.          Wputf("\033F%cTCXL  ", j);
  2476.          if(!DemoFast)
  2477.             _Delay(1);
  2478.       }
  2479.    }
  2480. }
  2481.  
  2482. /*----------------------------------------------------------------------*/
  2483. /* Sets up the [D]efaults menu for the pull-down demo.                   */
  2484.  
  2485. VOID  CTYP  SetupMenu(NOARG)
  2486. {
  2487.    WdrwHor(3, 0, 21, 0, LGREY|_BLUE);
  2488.    WdrwHor(8, 0, 21, 0, LGREY|_BLUE);
  2489. }
  2490.  
  2491. /*----------------------------------------------------------------------*/
  2492. /* Part of the window demo.                                             */
  2493.  
  2494. VOID  CTYP  SizeWindow(IntT r, IntT c)
  2495. {
  2496.    Wsize(r, c);
  2497.    DemoWait();
  2498. }
  2499.  
  2500. /*----------------------------------------------------------------------*/
  2501. /* Part of the window demo.                                             */
  2502.  
  2503. VOID  CTYP  TLineDemo(NOARG)
  2504. {
  2505.    if(0 == (w[3] = Wopen(10, 3, 23, 41, 3, YELLOW|_BLUE, LMAGENTA|_BLUE)))
  2506.       ErrorExit(1);
  2507.  
  2508.    HlpSet(H_TEXTLINE);
  2509.    Wputs("\n The WdrwHor() & WdrwVer() functions"
  2510.          "\n are used for drawing \"smart\" text"
  2511.          "\n lines which will even make their "
  2512.          "\n own corners and intersections!   ");
  2513.    PressAKey(6);
  2514.  
  2515.    HorzLine( 6,  6, 24, LCYAN|_BLUE);
  2516.    VertLine( 6,  6,  4, LCYAN|_BLUE);
  2517.    HorzLine(10,  6, 24, LCYAN|_BLUE);
  2518.    VertLine( 6, 30,  5, LRED|_BLUE);
  2519.    VertLine( 6, 18,  5, LRED|_BLUE);
  2520.    HorzLine( 7,  6, 25, LRED|_BLUE);
  2521.    HorzLine( 9,  6, 25, LGREEN|_BLUE);
  2522.    VertLine( 6, 11,  5, LGREEN|_BLUE);
  2523.    VertLine( 6, 23,  5, LGREEN|_BLUE);
  2524.    HorzLine( 8,  6, 25, LMAGENTA|_BLUE);
  2525. }
  2526.  
  2527. /*----------------------------------------------------------------------*/
  2528. /* Part of the window demo.                                             */
  2529.  
  2530. VOID  CTYP  TitleDemo(NOARG)
  2531. {
  2532.    if(0 == (w[2] = Wopen(5, 20, 19, 45, 3, LCYAN|_GREEN, WHITE|_GREEN)))
  2533.       ErrorExit(1);
  2534.  
  2535.    HlpSet(H_WINTITLE);
  2536.    Wputs("\n  The Wtitle() function"
  2537.          "\n  allows you to give a"
  2538.          "\n  window a title.");
  2539.    PressAKey(5);
  2540.  
  2541.    DisplayTitle(TTL_LFT);
  2542.    DisplayTitle(TTL_RGT);
  2543.    DisplayTitle(TTL_CNT);
  2544. }
  2545.  
  2546. /*----------------------------------------------------------------------*/
  2547. /* Toggles "block marking" on and off in the sample editor of the       */
  2548. /* pulldown menu demo                                                   */
  2549.  
  2550. VOID  CTYP  ToggleBlock(NOARG)
  2551. {
  2552.    LCL IntT    b = OFF;
  2553.  
  2554.    if(b)
  2555.    {
  2556.       b = OFF;
  2557.       ItmEna(32);
  2558.       ItmDis(33);
  2559.       ItmNxt(32);
  2560.    }
  2561.    else
  2562.    {
  2563.       b = ON;
  2564.       ItmDis(32);
  2565.       ItmEna(33);
  2566.       ItmNxt(33);
  2567.    }
  2568.    if(Wopen(11, 30, 15, 49, 0, LGREY|_MAGENTA, WHITE|_MAGENTA))
  2569.    {
  2570.       Wputf("\n Block is now o%s", b ? "n" : "ff");
  2571.       _Delay(10);
  2572.       Wclose();
  2573.    }
  2574. }
  2575.  
  2576. /*----------------------------------------------------------------------*/
  2577. /* Toggles the yes/no status of some pull-down menu items. This is to   */
  2578. /* show you can modify the menu item's string and redisplay it. This is */
  2579. /* done by getting the address of the current menu item's struct, then  */
  2580. /* modifying the string pointed to by the str element.  The redisp flag */
  2581. /* is set so that when you return to the menu, the screen will be       */
  2582. /* automatically updated.                                               */
  2583.  
  2584. VOID  CTYP  ToggleYN(NOARG)
  2585. {
  2586.    IdfP i;
  2587.    ChrP s, y;
  2588.    LCL ChrT yes[] = "yes", no[] = " no";
  2589.    i = ItmCur();
  2590.    s = ItmGet(IdfTag(i));
  2591.    y = s + strlen(s) - 3;
  2592.    strcpy(y, strcmp(y, yes) ? yes : no);
  2593.    ItmDsp(IdfTag(i));
  2594. }
  2595.  
  2596. /*----------------------------------------------------------------------*/
  2597. /* Updates the on-screen clock in the pull-down demo.                   */
  2598. /* Only updates the clock once per second.                              */
  2599.  
  2600. VOID  CTYP  UpdateClock(NOARG)
  2601. {
  2602.    LCL DwdT    t;
  2603.  
  2604.    if(t < (_Timer()))
  2605.    {
  2606.       Vprints(0, 70, LGREEN, SysTime(1));
  2607.       t = _Timer() + 18;
  2608.    }
  2609. }
  2610.  
  2611. /*----------------------------------------------------------------------*/
  2612. /* Part of the window demo.                                             */
  2613.  
  2614. VOID  CTYP  VertLine(IntT r, IntT c, IntT n, IntT a)
  2615. {
  2616.    WdrwVer(r, c, n, 3, a);
  2617.    DemoWait();
  2618. }
  2619.  
  2620. /*----------------------------------------------------------------------*/
  2621. /* Used by the List Picking demo to display a selected string, or       */
  2622. /* display an error message if an error occurred.  It also prompts for a*/
  2623. /* keypress 2 lines below the string/error message.                     */
  2624.  
  2625. VOID  CTYP  YouSelected(ChrP str)
  2626. {
  2627.    VposT rc;
  2628.  
  2629.    if(TcxlErr)
  2630.       Wputf("\033EL%s", WerrMsg());
  2631.    else
  2632.       Wputf("\033ELYou selected:  \033F\005%s\033F\004", str);
  2633.    HlpSet(H_LISTPICK);
  2634.    WcurGet(rc);
  2635.    PressAKey(VposR(rc) + 2);
  2636. }
  2637.  
  2638. /*- end of TcxlDemo.c --------------------------------------------------*/
  2639.